How to zip folder by using php class ziparchive up to 4gb on dreamhost?


am using ZipArchive Built-in Class to Zip the folders at runtime and save them on ftp

When I run my script at local host it easily make zip of size 540MB

But when I run script at my dev , page show me Internal Server Error though I increased the time limit too

Below is simple script to make zip.

$timeout = 5000 ;
ini_set(‘max_execution_time’, $timeout);
$zip_csv = new ZipArchive();

if ($zip_csv->open($csv_output, ZIPARCHIVE::CREATE) !== TRUE) {
die (“Unable to open Archirve”);

$all= new RecursiveIteratorIterator(new RecursiveDirectoryIterator($csv_folder));

foreach ($all as $f=>$value) {
$zip_csv->addFile(realpath($f), $f) or die (“ERROR: Unable to add file: $f”);

Can you please guide or suggest that what variables or settings need to be in php.ini to get it working


I’d be glad to give you a suggestion that might be of some help to you. I can’t promise it will work, but you might want to try increasing the upload_max_filesize and post_max_size limits as described here as well:

Cedric H


Is this on a front facing script, or running on the CLI ?

Remove set_time_limit(0); and test with PHP5.3 FastCGI