douxiong3245 2010-03-12 13:45
浏览 73
已采纳

使用Content-Disposition:并行附件发送文件

I have a PHP page that sends a file to the browser depending on the request data it receives. getfile.php?get=something sends file A, getfile.php?get=somethingelse sends file B and so on and so forth. This is done like so:

header('Content-Disposition: attachment; filename='. urlencode($filename));
readfile($fileURL);

It works except it can only send one file at a time. Any other files requested are send in linear fashion. One starts as soon as another finishes.

How can I get this to send files in parallel if the user requests another file while one is downloading?

Edit: I have tried downloading two files at the same time by directly using their filepaths and it works, so neither Apache, nor the browser seem to have a problem. It seems PHP is the issue. I have by the way used session_start() at the beginning of the page.

  • 写回答

2条回答 默认 最新

  • douxian1770 2010-03-15 09:26
    关注

    Adding session_write_close() right after I'm finished with the session and before starting the download seems to have solved the issue.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?