Installing PECL Zip Extension
I am trying to run this code
$files = array('readme.txt', 'test.html', 'image.gif');
$z开发者_如何学运维ip = new ZipFile;
$zip->open('file.zip', ZipArchive::CREATE);
foreach ($files as $file) {
$zip->addFile($file);
}
$zip->close();
header('Content-Type: application/zip');
header('Content-disposition: attachment; filename=filename.zip');
header('Content-Length: ' . filesize($zipfilename));
readfile($zipname);
And realized I had to install the PECL zip entension, which I believe I did corectly as once it was comopleted, it added this to my phpinfo();
Even after installing this extension, I'm still getting this message.
Fatal error: Class 'ZipFile' not found in
Have a look at the manual:
$zip = new ZipArchive();
The class is called ZipArchive
, not ZipFile
.
精彩评论