【发布时间】:2015-01-19 11:42:48
【问题描述】:
我正在尝试从网页下载一个大文件 (1.2GB)。当我想下载任何文件时,我应该先登录,我使用 curl 获取 cookie (PHPSESSID),然后我尝试下载这样的文件:
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.$filename[1]);
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Content-Length: ' . ($filesize[1]*1000000));
header('Pragma: public');
$opts = array(
'http'=>array(
'header'=>"Cookie: PHPSESSID=".$phpSesSid)
);
$context = stream_context_create($opts);
$handle = fopen($dwn, "r", false, $context);
if ($handle)
{
while (!feof($handle))
{
$buffer = fgets($handle, 4096);
echo $buffer;
ob_flush();
flush();
}
fclose($handle);
}
这个解决方案很好。该文件正在下载到〜150MB,然后我的浏览器停止下载文件并获取信息:“下载失败”。
我不知道哪里出了问题。当我查看“错误日志”时,我会收到以下错误:
[2015 年 1 月 19 日星期一 12:27:22] [警告] [客户端 178.183.xxx] (104)连接 对等方重置:mod_fcgid:从 FastCGI 服务器读取数据时出错
[2015 年 1 月 19 日星期一 12:27:22] [警告] [客户端 178.183.xxx] (104)连接 对等方重置:mod_fcgid:ap_pass_brigade 在 handle_request_ipc 中失败 功能
[2015 年 1 月 19 日星期一 12:27:22] [错误] [客户端 178.183.xxx] 文件没有 存在:/home/xx/domains/xx.yy.pl/public_html/500.shtml
哪里出了问题?你能帮帮我吗?
谢谢!
【问题讨论】: