Search code examples
phpzipphp-ziparchive

PHP: How to construct zip file from database (or binary file content)?


I need to create a zip file with PHP, but the source files are in database rather than stored on disk. Actually, file contents I want to pack are stored as binary in one database, and metas in another.

I have read the docs of class ZipArchive, but it seems that it could only pack files from disk (because file_names are required). I don't want to save files from database to disk, and then pack them, because it may slow down my application. Any other suggestions?


Solution

  • Have you tried ZipArchive::addFromString?