I would like to compress a directory using 7-Zip and then download it to a web browser.
However, instead of compressing to a file, then having PHP feed the contents of that file to the browser... I would ideally like to Have 7-Zip write the contents of the new archive to standard output as the archive is being created... While simultaneously having PHP flush its buffer and and send the data to the browser.
You see, the archive I'm creating is quite large. From a user's perspective, using the normal method, when they click "Download," the archive is first created and saved to a file (which can take ~ 10 minutes), and only then is the file then fed up by PHP to be downloaded. What I am trying to do is combine both the archive and output steps into one single process.
Does anyone have any input on this?
Here is someone else on SourceForge who is trying to do the same thing...
http://sourceforge.net/projects/p7zip/forums/forum/383043/topic/3828566
=======
Thank you for all help. I am going to close this thread, as I have recently discovered an excellent discussion on this topic already exists on StackOverflow. See:
LAMP: How to create .Zip of large files for the user on the fly, without disk/CPU thrashing
=======
This is the final solution I went with, and it is working fantastic for me. Note that I am using the "InfoZip" program, which you can find for pretty much any platform.
header('Content-Type: application/zip');
header('Content-disposition: attachment; filename="file.zip"');
header('Content-Transfer-Encoding: binary');
header('Accept-Ranges: bytes');
passthru("zip -8 -q -r - ./some_directory | cat");