3

as the subject, I have a problem with the content of a variable. Within into this variable is inserted a base64 of a file (extracted from an xml) and PHP the base64 to save the file in the filesystem. Everything is fine as long as there are small files (about 10MB) ... however the base64 with a file bigger the base64 seems to be "broken" after 9999993 characters. I say seems because if I go to the debug display the value of the variable I see all of the base64 string.

The problem is not in saving the file, because the file is created and saved correctly, but the content of the variable. Are there any limits to be set on php.ini? Or are there ways to remedy the problem? I also tried to split the string in chunks or in an array, but the problem remains.

I put the code I use to extract data from XML:

    $reader = new XMLReader(); 

    if (!$reader->open($GLOBALS['conf']['filepath'] . '/' . $xmlfile)) { 
        print "Error to open XML: $xmlfile\n"; 
    } else { 
        while ($reader->read()) { 
            $name = $reader->name; 
            $type = $reader->nodeType; 
            if (($type == XMLReader::ELEMENT) && in_array($name, $allowedNodes)) { 
                $xml = $reader->readOuterXml(); 

                $doc = new DOMDocument('1.0', 'UTF-8'); 
                $xml = simplexml_import_dom($doc->importNode($reader->expand(), true)); 

                //Other code
            } 
        } 
    }

Note: the variable $allowedNodes is a variable saved in a configuration file, so you do not see its value.

Thanks for the answers

4

1 回答 1

0

您是否尝试过用 gzcompress 替换 base64?

前段时间我也遇到过类似的问题,我用过,效果很好。我做了一个小的基准测试,内存不是一个大问题。

于 2013-01-30T16:24:45.920 回答