2012-01-24 29 views
2

我正在爲我的客戶端提供一個壓縮文件供下載,它適用於除IE以外的每個操作系統/瀏覽器。即使它聲稱成功,IE下載仍然不完整

壓縮文件爲550 MB。當我使用IE 8時,文件下載50到70 MB,然後聲稱即使原始文件是550 MB,下載也是完整的。

我想知道如果我錯過了一些需要的標題或東西。這裏是我用來提供文件的php代碼。

<?php 
header("Content-type: application/zip"); 
header("Content-Disposition: attachment; filename=$dnfilename"); 
header("Content-Length: ".filesize($ZIPFILE)); 
header("Pragma: no-cache"); 
header("Expires: 0"); 
readfile("$ZIPFILE"); 
?> 
+0

'它在每個操作系統/瀏覽器除了IE.'大驚喜:)。其他人是否可以重新解決這些問題,還是你是唯一一個對此進行過測試的人? –

+0

這發生在我的幾個客戶端,全部運行IE。 – ctown4life

+0

@ ctown4life - 我用IE 9試過了你的代碼,它對我來說工作的很好。下載1.5GB文件沒有任何問題。 IE 8的問題僅僅是這個問題嗎? – Cyclonecode

回答

0

我不知道這是否有幫助,但以下工作適用於IE8-9,Chrome和Firefox,使用1.5GB zip文件。

header("Pragma: public"); 
header("Expires: 0"); 
header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
header("Cache-Control: public"); 
header("Content-Description: File Transfer"); 
header("Content-type: application/octet-stream"); 
header("Content-Disposition: attachment; filename=\"".$dnfilename."\""); 
header("Content-Transfer-Encoding: binary"); 
header("Content-Length: ".filesize($ZIPFILE)); 
readfile($ZIPFILE); 

看一看這篇文章:HTTP Headers for ZIP File Downloads

+0

儘管我正確設置了標題,但這對我仍然是個問題。 –

0

我曾在IE7和IE8同樣的問題。 IE9和其他瀏覽器工作得很好。如果您更改了Content-Type標題,它將起作用。

變化

header("Content-type: application/zip"); 

header("Content-type: application/octet-stream"); 
相關問題