I was just playing around with PHP’s ability to create compressed files, and I had a problem. My ZIP file was not getting created but I wasn’t getting any errors.
$zip = new ZipArchive();
$zipFile = '/tmp/' . uniqid() . '.zip';
if (file_exists($zipFile)) {
unlink($zipFile);
}
$zip->open($zipFile, ZIPARCHIVE::CREATE);
foreach ($files as $type => $file) {
$zip->addFile($file);
}
$zip->close();
Now, pay particular attention to the files you are adding using addFile() as if you have entered them wrong, you won’t get an error message, and infact, if you use $zip->getStatusString() you will receieve a “No error” message – completely throwing you off the scent.
More information about ZipArchive can be found at http://www.php.net/manual/en/class.ziparchive.php