Search code examples
phpubuntuziplimitphp-ziparchive

PHP's native ZipArchive class fails when .zip is >= 4GB. How to fix?


PHP 5.3+'s native ZipArchive class (http://php.net/ziparchive) creates corrupt result files (.zip), but only when the result .zip is larger than ~4GB (i think 3,6 GB. Server is Ubuntu 10.10 64bit, 4GB RAM, latest PHP 5.3). The error (when unzipping this .zip, with whatever software you use) is:

file #1:  bad zipfile offset (lseek): 

According to several posting on the web this is simply the (undocumented) max limit for this class / the zip function. My question is: How to fix this, quick and dirty ? Are there some possible php.ini or server settings ? Or some other ways to create 4GB+ .zip files on native ubuntu systems ? I don't have root access and cannot install new packages.

There are some similar Q&As on this on Java: Zip files with Java: Is there a limit?


Solution

  • Wikipedia's quote :

    The original zip format had a 4 GiB limit on various things (uncompressed size of a file, compressed size of a file and total size of the archive), as well as a limit of 65535 entries in a zip archive.

    This is not a limitation of the class, but zip itself. You could switch to tar.gz for instance.