安装 PECL Zip 扩展
我正在尝试运行这段代码
$files = array('readme.txt', 'test.html', 'image.gif');
$zip = 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);
,并意识到我必须安装 PECL zip 扩展,我相信我是正确执行的,因为一旦它完成,它将它添加到我的 phpinfo();
即使安装此扩展程序后,我仍然收到此消息。
致命错误:找不到类“ZipFile”
I am trying to run this code
$files = array('readme.txt', 'test.html', 'image.gif');
$zip = 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看一下手册:
该类称为
ZipArchive
,而不是ZipFile
。Have a look at the manual:
The class is called
ZipArchive
, notZipFile
.