This is a discussion on fwrite and memory error within the PHP Language forums, part of the PHP Programming Forums category; I'm trying to save an XML file sent to me in ZIP format. Here is the code: if($XMLFile=...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I'm trying to save an XML file sent to me in ZIP format.
Here is the code: if($XMLFile=fopen($XMLPath.strtoupper(substr($file ,0,strlen($file)-4)).".XML",'w')) if(fwrite($XMLFile,zip_entry_read($zip_entry,zip_e ntry_filesize($zip_entry)))){ here is the error: Allowed memory size of 8388608 bytes exhausted (....) The problem occurs on the "fwrite" function. This appens when the XML file is very large (seems more than the 8mb limit). I can't change this size server side, as my ISP doesn't allow me to do that. Hot to fix the problem script side ??? Bob |
|
|||
|
Bob Bedford wrote:
>if($XMLFile=fopen($XMLPath.strtoupper(substr($fil e,0,strlen($file)-4)).".XML",'w')) >if(fwrite($XMLFile,zip_entry_read($zip_entry,zip_ entry_filesize($zip_entry)))){ Try not writing the entire zip at once, but do it a bit at a time so there never has to exist a variable that is larger than 8 MB. -- Rasmus Rimestad, webprogrammer http://www.rimestad.no/en ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups ----= East and West-Coast Server Farms - Total Privacy via Encryption =---- |
|
|||
|
"Rasmus Rimestad" <""rasmus\"@rimestad.n0sp@am.no"> a écrit dans le message
de news: 42075446_2@127.0.0.1... > Bob Bedford wrote: > > >if($XMLFile=fopen($XMLPath.strtoupper(substr($fil e,0,strlen($file)-4)).".XML",'w')) > > >if(fwrite($XMLFile,zip_entry_read($zip_entry,zip_ entry_filesize($zip_entry)))){ > > > Try not writing the entire zip at once, but do it a bit at a time so there > never has to exist a variable that is larger than 8 MB. I've been looking around without finding a way to do so. Could you please tell me how ? Bob |
|
|||
|
The manual says that if you do not specify the size you want to read in
zip_entry_read then it will read 1024 bytes. Have you tried something like this? while($size < zip_entry_filesize($zip_entry)) { fwrite($XMLFile,zip_entry_read($zip_entry)); $size += 1024; } Rasmus Rimestad Web databases at a price you can live with -> http://www.rimestad.no |