Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 442
SenorPuerco Avatar asked Dec 12 '25 07:12

SenorPuerco


2 Answers

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.

like image 151
cweiske Avatar answered Dec 14 '25 19:12

cweiske


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.

like image 27
sanjeev ranjan Avatar answered Dec 14 '25 21:12

sanjeev ranjan