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 ZipArchiv开发者_C百科e 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?
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.
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
精彩评论