PHP 的 zipArchive 类的大小限制? [英] Size limit on PHP's zipArchive class?

查看:61
本文介绍了PHP 的 zipArchive 类的大小限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用 PHP 创建一个 zip 文件供用户下载.我没有从 PHP 或检查 zipArchive 类的 GetStatusString 函数中得到任何错误.但是如果我将一些文件放入存档中,那么当我尝试打开它时,我会收到错误消息压缩(zipped)文件夹无效或损坏".我检查了我添加的所有文件,它们都很好.我唯一能想到的是较大的文件会导致问题.但是大"文件只有大约半兆字节,我找不到任何关于 zipArchive 文件大小限制的文档.关于其他尝试的任何想法,以便我可以追踪这个问题?谢谢.

我已将其范围缩小到一个导致问题的特定文件.还有其他的工作也一样大或更大,所以我想扔掉那个想法.以下是工作正常的文件名示例:

627 Jane.CCD.pdf
712 Example_DrNotes.pdf
第625话

是的,文件名中有空格...继承代码问题.这是不起作用的文件名:

623 Jane.Labs.pdf

似乎不是文件名问题.这最终会通过网络传播,但我正在检查它在服务器上制作的实际 zi​​p 文件,这就是我收到错误的地方.

代码如下:

$zip = new ZipArchive();$zfileName = $GLOBALS["localUploadRoot"] .$zfile;$requests = $this->getRequests(true);foreach ($requests AS $r) {if (file_exists($GLOBALS["localInboundRequests"] . $r["file"])) {$zip->addFile($GLOBALS["localInboundRequests"] . $r["file"], $r["file"]);}}$zip->close();

编辑 2:抱歉,我无法发布文件.里面有个人信息.

解决方案

除非您使用 zip64,否则 Zip 文件中的文件限制为 4 GB(未压缩文件大小),而 php 尚不支持.参见 http://bugs.php.net/bug.php?id=51353.

I'm creating a zip file in PHP for the user to download. I get no errors from PHP or from checking the zipArchive class's GetStatusString function. But if I put some files into the archive, then when I try to open it, I get the error "the compressed (zipped) folder is invalid or corrupted". I've checked all the files I'm adding, they are all good. The only thing I can think of is that the larger files are causing problems. But the "large" file is only about half a megabyte, and I can't find any documentation about a file size limit for zipArchive. Any thoughts on other things to try, so I can track down this problem? Thanks.

Edit: I've narrowed it down to one specific file that is causing trouble. There are others that work that are as big or bigger, so I guess throw out that thought. Here are examples of filenames that are working fine:

627 Jane.CCD.pdf
712 Example_DrNotes.pdf
625 Jane.Labs2.pdf

Yes, there are spaces in the filenames...inherited code issue. Here is the filename that does not work:

623 Jane.Labs.pdf

Doesn't seem like it could be a filename issue. This will eventually be over the web, but I'm checking the actual zip file it makes on the server and that's where I'm getting the error.

Here's the code:

$zip = new ZipArchive();
$zfileName = $GLOBALS["localUploadRoot"] . $zfile;
$requests = $this->getRequests(true);
foreach ($requests AS $r) {
    if (file_exists($GLOBALS["localInboundRequests"] . $r["file"])) {
        $zip->addFile($GLOBALS["localInboundRequests"] . $r["file"], $r["file"]);
    }
}
$zip->close();

Edit 2: Sorry, I can't post the file. It has personal information in it.

解决方案

The limit for files in Zip files is 4 gigabytes (uncompressed file size) unless you use zip64, which is not supported yet in php. See http://bugs.php.net/bug.php?id=51353.

这篇关于PHP 的 zipArchive 类的大小限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆