I want to create a zip file in PHP and use the header() function to make it downloadable without having to save the file on the server. But I think the built in ZipArchive can't do this. I found a few that can, but they all add files from existing files, and I need to add it like ZipArchive::addFromString() does.
Does someone knows a class or something with this capabilities?
gzip does it for a file. and for an archive you can use gzip and tar as follows.
tar -cz thedir
this is how to do it with zip.
zip - file1.txt file2.txt
According to the PHP compression streams documentation ZipArchive registers the zip://
stream wrapper. While I never worked with zip://
streams you could check out if zip.compress
works. You can build a test from another example found here .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.