2014-04-02 59 views
1

下面的代碼顯示的是二進制數據,而不是顯示PDF文件的下載對話框。二進制輸出代替PDF文件的下載對話框

我在做什麼錯?

header("Pragma: public"); 
    header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); 
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
    header('Content-Type: application/octet-stream'); 
    header("Content-Disposition: attachment; filename=\"".basename($filepath)."\";"); 
    header("Content-Transfer-Encoding: binary"); 
    header("Content-Length: ".filesize($filepath)); 
    readfile($filepath); 

exit;

already tried application/pdf but no luck ! 
+0

這應該通常工作。您是否嘗試過使用其他瀏覽器? – blue

+0

是的嘗試FF和Chrome – user1421214

+0

我不確定它是否會幫助,但嘗試刪除文件名末尾的「**; **」。 – blue

回答

1

更換應用程序/八位字節流應用/ PDF,然後再試一次。

+0

已經嘗試過。沒有運氣 – user1421214