2015-12-30 16 views
0

鉻,歌劇,Safari瀏覽器中發生的發佈錯誤,只適用於Firefox。 這裏的標題:錯誤:從服務器收到的重複標題

| Header 
    | Forcing a download using readfile() 
    |---------------- 
    */ 

    header('Content-Description: File Transfer'); 
    header('Content-Type: ' . $file_mime_type); 
    header('Content-Disposition: attachment; filename=' . $file); 
    header('Content-Transfer-Encoding: binary'); 
    header('Expires: 0'); 
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); 
    header('Pragma: public'); 
    header('Content-Length: ' . $file_size); 
    ob_clean(); 
    flush(); 
    readfile($file_path); 
    exit; 

我試圖把雙引號和作品,但增加了文件名稱 - 例如-'filename.pdf '

header("Content-Disposition: attachment; filename= . '$file'"); 
+0

你不能有2'頭(' 內容簡介:...'在同一時間 – Armen

+0

你是什麼意思?刪除第一行 - 標題('Content-Description:File Transfer'); –

回答

0

要解決問題,您需要

// Change this 
header('Content-Disposition: attachment; filename=' . $file); 

// To this 
header('Content-Disposition: attachment; filename="'.$file.'"'); 
+0

真棒現在適用於所有瀏覽器。實際上它是這個腳本http://www.tutorialchip.com/php-download-file-script/我認爲它是因此有一個問題。 –

+0

Content-Description與Content-Disposition是否相同? – Barmar

+0

Ups :)我的壞@Barmar,他的問題只是配額,u pdating答案 – Armen

相關問題