简体   繁体   English

PHP的zipArchive类的大小限制?

[英]Size limit on PHP's zipArchive class?

I'm creating a zip file in PHP for the user to download. 我正在用PHP创建一个zip文件供用户下载。 I get no errors from PHP or from checking the zipArchive class's GetStatusString function. 我从PHP或检查zipArchive类的GetStatusString函数没有错误。 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. 但“大”文件只有大约半兆字节,我找不到任何有关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 627 Jane.CCD.pdf
712 Example_DrNotes.pdf 712 Example_DrNotes.pdf
625 Jane.Labs2.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 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. 这最终将通过网络,但我正在检查它在服务器上的实际zip文件,这就是我收到错误的地方。

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. 编辑2:抱歉,我无法发布文件。 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. Zip文件中的文件限制是4千兆字节(未压缩文件大小),除非您使用zip64,这在php中尚不支持。 See http://bugs.php.net/bug.php?id=51353 . http://bugs.php.net/bug.php?id=51353

the limit of zip file is 4GB(compressed file). zip文件的限制是4GB(压缩文件)。 if compressed file size will be greater than 4GB then unzip will not be possible. 如果压缩文件大小将大于4GB,则无法解压缩。 so, better way to split your zip file in 4GB. 所以,更好的方法来分割你的4GB的zip文件。

Due to the natural file size limit of 4GB (~3,6GB to be correct) of zip files, this class will generate corrupt files of the result is larger than 4 GB. 由于zip文件的自然文件大小限制为4GB(约3,6GB是正确的),此类将生成损坏的文件,结果大于4 GB。 Using tar.gz is a proper alternative. 使用tar.gz是一个合适的选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM