简体   繁体   中英

Size limit on PHP's zipArchive class?

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 .

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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