php zip.so 编译出错,PHP Zip创建类ZipArchive未找到错误

论坛 期权论坛 编程之家     
选择匿名的用户   2021-6-2 16:36   1433   0

我正在尝试根据我发现的内容创建一个zip脚本

here但我似乎遇到致命错误:新的ZipArchive()上没有找到类’ZipArchive’错误;功能.

研究这似乎通常是由于PHP的编译方式.我有一个共享主机帐户,所以我没有配置任何这些东西……我认为我不能对构建进行任何更改.出于兴趣,我看了一下我的phpinfo(),我找到了一些看似相关的东西:

PHP版本5.2.6

BZip2 Support Enabled

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

我并不十分确定这是否意味着我有能力创建拉链.

有关更多信息(虽然我不认为它是重温的)这里是我的脚本到目前为止….这是未经考验的头脑你,因为我无法得到这个类未找到错误.

$file = tempnam("tmp", "zip");

$zip = new ZipArchive();

$zip->open($file, ZipArchive::OVERWRITE);

//the string "file1" is the name we're assigning the file in the archive

$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');

// echo $zip->file(); //this sends the compressed archive to the output buffer instead of writing it to a file.

$zip->close();

header('Content-Type: application/zip');

header('Content-Length: ' . filesize($file));

header('Content-Disposition: attachment; filename="' . $file.'"');

readfile($file);

unlink($file);

所以我的问题确实是:

>我在脚本中做了什么导致此错误?

>我的phpinfo()中的任何东西是否意味着我应该能够创建zip文件,如果我不应该在那里寻找什么,如果我有能力将让我知道.

>看起来这个ZLib是一些软库,但我不知道它是否做了我想做的事情,甚至不知道如何使用它….这有点像预感,但如果可以的话帮我创建zip文件谁能指点我如何使用它的正确方向?

提前致谢.

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP