douqie6454
2011-08-02 21:42
浏览 155
已采纳

安装PECL Zip扩展

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();

enter image description here

Even after installing this extension, I'm still getting this message.

Fatal error: Class 'ZipFile' not found in

图片转代码服务由CSDN问答提供 功能建议

我正在尝试运行此代码

  $ 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拉链插件,我相信我已经完成了核心工作,因为一旦它被复制,它就把它添加到我的phpinfo();

即使安装了此项 扩展,我仍然收到此消息。

致命错误: 中找不到类'ZipFile'

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • du5910 2011-08-02 21:47
    已采纳

    Have a look at the manual:

    $zip = new ZipArchive();
    

    The class is called ZipArchive, not ZipFile.

    点赞 评论

相关推荐 更多相似问题