Reputation: 10117
I'm wanting to generate a dynamic zip/gzip file using php (user clicks button/link/whatever, and sends file to download) which contains a folder structure that may or may not have files (could be blank or contain data) in all the folders.
The aim is to be able to unzip this file and have a folder/file structure ready to go.
I believe I am familiar with everything involved, except how to generate the file without creating the files on my server locally, then zipping them and sending for download. This seems to include 'writing the files to the server' as a sort of middle man that I would just assume bypass if possible.
I would like to assume this is as easy as sending raw data to the browser with a zip/gzip header, but I haven't had much luck finding any information on this.
Any pointers in the right direction would be most helpful.
Upvotes: 1
Views: 1359
Reputation: 24969
You can do that with the ZipArchive
class. Have a look at function such as ZipArchive::addFromString()
which will allow you to add files to the archive without actually saving it them to disk first.
Upvotes: 3