Generating ZIP files with PHP + Apache on-the-fly in high speed?

后端 未结 5 1577
日久生厌
日久生厌 2020-12-15 10:34

To quote some famous words:

“Programmers… often take refuge in an understandable, but disastrous, inclination towards complexity and ingenuity in thei

5条回答
  •  情歌与酒
    2020-12-15 11:24

    You can use ZipStream or PHPZip, which will send zipped files on the fly to the browser, divided in chunks, instead of loading the entire content in PHP and then sending the zip file.

    Both libraries are nice and useful pieces of code. A few details:

    • ZipStream "works" only with memory, but cannot be easily ported to PHP 4 if necessary (uses hash_file())
    • PHPZip writes temporary files on disk (consumes as much disk space as the biggest file to add in the zip), but can be easily adapted for PHP 4 if necessary.

提交回复
热议问题