Size limit on PHP's zipArchive class?

可紊 提交于 2019-12-24 00:19:00

问题


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.


回答1:


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.




回答2:


the limit of zip file is 4GB(compressed file). if compressed file size will be greater than 4GB then unzip will not be possible. so, better way to split your zip file in 4GB.




回答3:


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. Using tar.gz is a proper alternative.



来源:https://stackoverflow.com/questions/3472650/size-limit-on-phps-ziparchive-class

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!