Size limit on PHP's zipArchive class?

SenorPuerco picture SenorPuerco · Aug 13, 2010 · Viewed 8.7k times · Source

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.

Answer

cweiske picture cweiske · Sep 24, 2010

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.