【问题标题】:Apache freeze when try to download a file?尝试下载文件时Apache冻结?
【发布时间】:2013-03-07 12:53:49
【问题描述】:

当我尝试从http://timmytheterror.com/home/music_detail/233下载音乐文件时

使用用户名登录:amar 密码:123456 开始下载但 apache 停止处理其他请求。在下载完成之前,我无法访问其他页面。我要下载的编码是

$path = base64_decode($path); $id = base64_decode($id);

        $file_path= "http://timmy-the-terror.s3.amazonaws.com/".$path;

        header('Content-Type: application/octet-stream');
        header("Content-Transfer-Encoding: Binary"); 
        header("Content-disposition: attachment; filename=\"".$path."\""); 
    header("Cache-Control: public");
    header("Location: $file_path");
    readfile($file_path); 

我在单独的窗口中打开它,但父窗口仍然停止响应。

【问题讨论】:

标签: php apache file download


【解决方案1】:

尝试添加 session_write_close();到下载脚本。它将停止进一步写入您的会话,并允许使用该会话的其他脚本/页面继续。

session_write_close();
$file_path= "http://timmy-the-terror.s3.amazonaws.com/".$path;

header('Content-Type: application/octet-stream');
header("Content-Transfer-Encoding: Binary"); 
header("Content-disposition: attachment; filename=\"".$path."\""); 
header("Cache-Control: public");
header("Location: $file_path");
readfile($file_path); 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-03
    • 2014-05-05
    • 2015-02-16
    • 1970-01-01
    相关资源
    最近更新 更多