ZipArchive not working!


I’m using PHP 5.2.6, and the ZipArchive function just doesn’t work.

Please take a look at the following code:

   $zip = new ZipArchive;
   $zip->open("", ZipArchive::CREATE);
   $zip->addFile("File.php", "File.php");

Even though if I manually create and put it in that folder, it still won’t add File.php into the archive,

Thanks in advance

PS: it doesn’t show any errors, even its E_ALL,

Try this:

$zip = new ZipArchive;
$r = $zip->open('', ZipArchive::CREATE);

$r = $zip->addFile('test.php', 'test.php');

$r = $zip->close();

what is the output?
what operating system?


Thanks for your help.

I used that code, but it doesn’t show anything at all, just a blank screen :(. is it because the errors or disabled or what, I’m also using error_reporting(E_ALL);, but still its a blank screen.

Please take a look at my phpinfo():


Check the folder permissions. From the PHP Manual user notes:

rickky at gmail dot com (02-Jul-2007 01:07)

If the directory you are writing or saving into does not have the correct permissions set, you won’t get any error messages and it will look like everything worked fine… except it won’t have changed!
Instead make sure you collect the return value of ZipArchive::close(). If it is false… it didn’t work.

Still doesn’t explain why var_dump() doesn’t display the return values in your case though.

I’ve changed it to 777, still blank screen :frowning:

According to your phpinfo(), the Zip extension is not installed. If it was, you’d see something like this:


Zip enabled
Extension Version $Id: php_zip.c,v 2006/09/24 22:27:57 pajoye Exp $
Zip version 2.0.0
Libzip version 0.7.1

It’s amazing that you’re not getting “class doesn’t exist” error messages. Something must be going on with your error handling.

Yes exactly, it might be zip not enabled, but the damn problem is even if I use a strange class name which would never exist, it still doesn’t give any error :frowning:

I’ll deal with my server guys now,

Thanks for your help