Creating Large Zip Archives on the Fly

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pablo54
Forum Newbie
Posts: 1
Joined: Fri Feb 09, 2007 6:51 pm

Creating Large Zip Archives on the Fly

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
Post Reply