Page 1 of 1

Creating Large Zip Archives on the Fly

Posted: Fri Feb 09, 2007 7:16 pm
by pablo54
I'm currenly working on a project that requires the creation of a zip file, on the fly in php, that contains multiple mp3 files from 2MB to 4MB per file, with a maximum number of files being between 10 and 15 per archive. Once created the file is downloaded to the client and then deleted.

The PHP classes I've tried (like phpZIP PRO) all store the contents of the zip in memory. I realize that by increasing post_file_size and upload_max_filesize in php.ini I can probably get it to work in development, but my concern is that in production it will be too much of a load.

Are there any methods of creating large zip archives on the fly that don't require the whole file to be loaded into memory? I've read about using tar or gzip through the system() function, but am not sure that will help.

Linux/Apache/PHP 4.4.4

Thanks

Posted: Fri Feb 09, 2007 7:32 pm
by feyd
The directives you have referred to affect uploading of files to the server through PHP, not the creation of a file in memory. Memory_limit is the directive you would need to alter.

There is a Zip class that one of our users posted in Code Snippets. I don't recall how it creates the files, but it may be of interest.