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


#1

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);
set_time_limit(0);
$csv_folder=“clients/”;
$csv_output=“clients.zip”;
$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”);
}
$zip_csv->close();

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


#2

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: http://wiki.dreamhost.com/PHP.ini#Increase_Filesize_Upload_Limit

Thanks
Cedric H


#3

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

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