我有一個函數用於輸出文檔,圖片等:頭()的問題在IE
public function direct($theMimeType, $thePath)
{
header('Content-type: '.$theMimeType);
ob_clean(); // clean output buffer
flush(); // flush output buffer
readfile($thePath);
exit;
}
在Firefox的偉大工程。無論是PDF,DOCX還是任何其他文件,該文件都會打開。然而,在IE中它凍結並沒有任何顯示。
這是什麼原因造成的?
編輯:
我加入了一些其他的標題:
public function direct($theMimeType, $thePath)
{
$aSize = filesize($thePath);
$aBegin = 0;
$aEnd = $aSize;
$aFilename = end(explode('/', $thePath));
$aTime = date('r', filemtime($thePath));
$aContentDisposition = ('application/pdf' === $theMimeType) ? 'inline' : 'atachment';
header('HTTP/1.0 200 OK');
header("Content-Type: $theMimeType");
header('Cache-Control: public, must-revalidate, max-age=0');
header('Pragma: no-cache');
header('Accept-Ranges: bytes');
header('Content-Length:'.($aEnd-$aBegin));
header("Content-Range: bytes $aBegin-$aEnd/$aSize");
header("Content-Disposition: $aContentDisposition; filename=$aFilename");
header("Content-Transfer-Encoding: binary\n");
header("Last-Modified: $aTime");
header('Connection: close');
ob_clean(); // clean output buffer
flush(); // flush output buffer
readfile($thePath);
exit;
}
那麼,它在IE現在但仍打開該文件時比Firefox慢得多。在IE瀏覽器打開文件之前似乎有幾秒鐘凍結。
我們需要更多信息,比如「你還發送了什麼其他的頭文件?」 – 2010-10-06 09:56:28
沒有其他的標題。我只是使用Content-type。 – 2010-10-06 10:17:01
@Mark Baker:檢查我更新的問題。我添加了其他幾個標題。 – 2010-10-06 10:19:36