开发者

How to download multiple files together from a database in PHP

I know how to download a single file from a databas开发者_运维问答e in PHP. How can I download multiple files together from a database?


You can theoretically do multipart to push multiple files, but I think it will be exceedingly difficult. Perhaps you can zip the files up and then push the zip to the browser?


I think you can't push multiple files at the same time in php. Since you have to set the MIME type of it, you can't set multiple headers at the same time.

You may be able to push files one after another, especially if you have to push files of different types. Output buffering can be used for it.

  1. Start output buffering.
  2. Set MIME type of the file to be downloaded.
  3. Prepare the file contents in buffer.
  4. Get the buffer contents and push it for download.
  5. Clean buffer.

repeat until all files are downloaded. Its better to store all files in server temporarily, then compress and push it as single file.


I've never done anything like this, so this is more of a guess/suggestion/idea, but could you have a list somewhere with all the files you want to send and when each file is sent its marked/erased from the list; then you refresh the page and go down to the next file in the list ? Not sure if this would work not, just my 2 cents.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜