0

我编写了一个小型下载门户,并使用 application/octet-stream 下载文件。

function fu($filename)
{
     header("Content-Type: application/octet-stream");  
     $save_as_name = basename($filename);   
     header("Content-Disposition: attachment; filename=\"$save_as_name\""); 
     readfile($filename);   
}

当我下载一个大文件时,在下载完成之前无法浏览目录树。

有没有机会并行执行此操作?

4

1 回答 1

0

You're probably using sessions. While you have a session open in Window A which is busy serving the download Window B will not be able to get any pages because the PHP process serving A still has the session data open/locked and B is waiting on that lock to be released.

The simple solution is to call session_write_close() at some point before you call readfile(). This will commit the session to disk on the server, close it, and release the lock so other PHP processes can pick it back up.

于 2013-02-22T16:10:56.423 回答