Sometimes we all programmer need to Compressing a directory of files with PHP. And it can’t be easier than that – if you have a folder, which contains a number of other folders and files in them the script below lets you add to the zip file quickly and easily:

$images_dir = '/path/to/images';
//this folder must be writeable by the server
$backup = '/path/to/backup';
$zip_file = $backup.'/backup.zip';
if ($handle = opendir($images_dir))  
{
$zip = new ZipArchive();
if ($zip->open($zip_file, ZIPARCHIVE::CREATE)!==TRUE) 
{
exit("cannot open <$zip_file>\n");
}
while (false !== ($file = readdir($handle))) 
{
$zip->addFile($images_dir.'/'.$file);
echo "$file\n";
}
closedir($handle);
echo "numfiles: " . $zip->numFiles . "\n";
echo "status:" . $zip->status . "\n";
$zip->close();
echo 'Zip File:'.$zip_file . "\n";
}

Are you want to get implementation help, or modify or extend the functionality of this script? Submit paid service request