PHP下载会阻止其他请求

我使用一个非常简单的脚本从我的服务器下载文件:

header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($fichero));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);

它工作正常,但在浏览器下载文件时,我无法浏览网站或从同一服务器下载其他文件.我必须等到它完成.它发生在Chrome& Firefox和我也使用其他方法用PHP下载文件,但是所有这些我都有这个问题…所以我想这是服务器中的问题?

非常感谢你提前:)

解决方法:

这是因为您正在使用PHP会话,并且在一个请求中打开一个用户的会话时,无法在其他请求中打开同一会话.

在readfile()之前执行session_write_close().

上一篇:PHP-Apache在提供文件之前会先读取锁定文件吗?


下一篇:linux – 发生错误时发布flock?