quick_learner42 quick_learner42 - 10 months ago 84
PHP Question

php zip archive memory, ram and max file size

I have folders that have user generated images that get rather large. When trying to zip these I am getting errors around 1.5 gig sized zip files.

My questions have to do with memory and I think that php is holding both the zip open and all the images in memory. A possible solution I have is to send each image on upload to the zip file in addition to the appropriate folder, this seems to work so far but what are the limits of the zip file size, from what I can find around 4 gb. How does this affect/interact with the amount of ram on the server?\ and is the limit actually 4gb or can I continue to add files to the zip indefinitely or should I have the script check the size of the zip and if it's over X gigs rename it and create a new zip. I have searched google and read the documentation but have found conflicting information or incomplete info so I'm looking for some definitive answers and advice. Thanks

Answer Source

Use php exec and call a zip tool on the command line

 exec("tar -zcvf archive.tar.gz /folder/tozip");

Be sure that the user who is executing the php file has access to the folder you want to zip

And take care of injection code.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download