Manipulate an Archive in memory with PHP (without creating a temporary file on disk)

后端 未结 5 1086
太阳男子
太阳男子 2020-11-27 05:06

I am trying to generate an archive on-the-fly in PHP and send it to the user immediately (without saving it). I figured that there would be no need to create a file on disk

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-27 05:28

    You need to use ZipArchive::addFromString - if you use addFile() the file is not actually added until you go to close it. (Horrible bug IMHO, what if you are trying to move files into a zip and you delete them before you close the zip...)
    The addFromString() method adds it to the archive immediately.

提交回复
热议问题