Page 1 of 1

Problems with ZipArchive

Posted: Wed May 16, 2007 10:43 pm
by Giddeon Fox
This may seem like the basic bad configuration problem, but keep reading. It gets interesting. Or maybe it is just a basic bad configuration problem.

Anyway, whenever I try to use the ZipArchive class, I get "Fatal error: Class 'ZipArchive' not found." Oh, of course! I didn't add the DLL in php.ini

But I did. phpinfo even says I did. It also says zlib is working fine, too. What gives? I can access the standard zip functions, but anything having to do with the class returns that message. Here's my code:

Code: Select all

<?php
$images = $_POST['images'];
$zip = new ZipArchive();
$filename = "./images.zip";

if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) {
    exit("cannot open $filename\n");
}

foreach($images as $curimage)
{
	$tmp = pathinfo($curimage);
	$zip->addFile($tmp[basename]);
}
$zip->close();
?>
If you'd like to see my phpinfo or php.ini, just ask.

So what gives? Did I configure something wrong? Did I type something wrong? Thank you in advance for any help. And if it is just a dumb configuration error, feel free to berate me for wasting your time.

Posted: Thu May 17, 2007 12:32 am
by feyd
There's no "ZipArchive" class listed as being apart of the zlib extension.

Posted: Thu May 17, 2007 6:17 am
by Giddeon Fox
Well maybe it wasn't zlib... One of those Z's... Here's PHP.net's page on it. It says "This extension uses the functions of ยป zlib by Jean-loup Gailly and Mark Adler." Is this a different zlib? Am I missing a different library? I'm using PHP 5.2.0, by the way. So if it's not in zlib, where is it? Does it even exist?