我能夠在「chrome」和「FF」瀏覽器中使用PHP代碼壓縮文件夾並下載zip文件。但是當我在IE8中嘗試時,它會將下載的zip文件顯示爲未知類型的文件。我將不得不使用rar應用程序來打開它,但我希望將此zip文件直接下載爲IE8中的.zip文件,因爲它在其他瀏覽器中發生。以下是我用它的標題:在ie8中使用php下載zip文件
header("Pragma: public");
header("Pragma: no-cache");
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/zip");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($archive_file_name));
header("Content-Disposition: attachment; filename=$archive_file_name");
readfile("$archive_file_name");
unlink($archive_file_name);
有人可以讓我知道我需要更正代碼嗎?由於
是在$ archive_file_name僅僅是壓縮文件名,而不是路徑。我也將't'改爲'T',但它仍然不起作用。請告訴我,如果您需要更多關於這個 – user1489969
@ user1489969的信息 - 請嘗試減少剛剛擁有的頭部數量,content-type和content-disposition標頭,並確保文件名是Url Encoded urlencode($ archive_file_name)。 –
我剛剛通過只有以下幾行來嘗試:header(「Content-Disposition:attachment; filename = $ archive_file_name」); header(「Content-Type:application/zip」); readfile(「$ archive_file_name」); unlink($ archive_file_name);仍然沒有在IE8中工作。請讓我知道是否有其他需要的信息 – user1489969