使用IE7 IE8通过SSL从PHP Web应用程序发出间歇性下载错误

时间:2010-05-06 11:20:27

标签: php ssl download internet-explorer

这些是大型(20-60mb)的quickbooks文件。看似随机,正在下载它们的IE用户得到“服务器返回无效或无法识别的响应”,并且下载失败。

在其他浏览器中100%有效。

这是通过SSL。这些下载正在被迫,我已经尝试过我所见过的各种标题。目前:

@ob_end_clean();
    if(ini_get('zlib.output_compression')) ini_set('zlib.output_compression', 'Off');

    header('Content-Type: application/force-download');
    header('Content-Disposition: attachment; filename="'.$file->original_name.'"');
    header("Content-Transfer-Encoding: binary");
    header('Accept-Ranges: bytes');


    header("Cache-Control: public, must-revalidate");
    header("Pragma: hack");
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");

    $size = filesize($_SERVER['DOCUMENT_ROOT'].'/uploads/'.$file->name);

    header("Content-Length: ".$size);

    $new_length = $size;
    /* output the file itself */
    $chunksize = 1*(1024*1024); //you may want to change this
    $bytes_send = 0;
    if ($file_h = fopen($_SERVER['DOCUMENT_ROOT'].'/uploads/'.$file->name, 'rb'))
    {

        while
            (!feof($file_h) && 
             (!connection_aborted()) && 
             ($bytes_send<$new_length) )
        {
            set_time_limit(5);
            $buffer = fread($file_h, $chunksize);
            echo($buffer); 
            flush();
            $bytes_send += strlen($buffer);
        }
    fclose($file_h);
    }

    die();

1 个答案:

答案 0 :(得分:0)

正如我所看到的,问题来自Pragma头字段,当它设置为“no-cache”时,这似乎不是你的问题。您是否使用任何工具[如Firefox Live Headers]来检查Pragma字段的值?