I am trying to create a zip script based on what I found here , but I seem to get a fatal error: Class 'ZipArchive' no error was detected in the new ZipArchive (); function.
Researching this seems like it's usually related to how PHP is compiled. I have a shared hosting account, so I haven’t configured any of this stuff ... and I assume that I can’t make any changes to the assembly. Out of interest, I looked into my phpinfo (), and I found some things that looked related:
PHP Version 5.2.6
BZip2 Support Enabled <--maybe not so relevant
ZLib Support enabled
Stream Wrapper support compress.zlib://
Stream Filter support zlib.inflate, zlib.deflate
Compiled Version 1.1.4
Linked Version 1.1.4
I'm not sure if any of this means that I have the ability to create zip codes. For more information (although I don’t think it is relivent) here is my script so far .... this is untested by the mind, since I can not get a phased this error class was not found.
$file = tempnam("tmp", "zip");
$zip = new ZipArchive();
$zip->open($file, ZipArchive::OVERWRITE);
$zip->addFile('show1.jpg', 'file1.jpg');
$zip->addFile('show2.jpg', 'file2.jpg');
$zip->addFile('show3.jpg', 'file3.jpg');
$zip->addFile('show4.jpg', 'file4.jpg');
$zip->addFile('show5.jpg', 'file5.jpg');
$zip->addFile('show6.jpg', 'file6.jpg');
$zip->close();
header('Content-Type: application/zip');
header('Content-Length: ' . filesize($file));
header('Content-Disposition: attachment; filename="' . $file.'"');
readfile($file);
unlink($file);
So my questions really are:
- Am I doing anything in my script to cause this error?
- Any of these materials from my phpinfo () means that I should be able to create zip files, .. not what I should look for there, which will let me know if I have the opportunity.
- It seems that this ZLib is a kind of library, but I have no idea if it does what I want, or even how to use it ... it's a little hunch, but if it can help me create zip files, can anyone -Never point me in the right direction, how to use it?
.
Dan