2013-05-02 134 views
1

我在php應用程序中附加了outlook msg文件。我將該文件存儲在SQL Server數據庫中。在瀏覽器中使用php顯示.msg文件

現在我想打開並顯示它從瀏覽器。

我試過這段代碼:

if($ext=="msg") 
    { 
    header('ContentType : application/octet-stream'); 
    header('Content-Disposition: attachment; filename='. basename($filename)); 
    echo base64_decode($file); 
    } 

$文件名和文件$從數據庫中來。

它的開放msg文件在IE瀏覽器和Chrome瀏覽器,但它不是從Firefox開放。

有什麼辦法讓它在所有瀏覽器中都能正常工作嗎?

或者我錯了某處或在瀏覽器中有任何設置?

+0

這可能是Firefox的默認行爲。檢查工具 - 。選項 - >應用程序選項卡。 – 2013-05-03 00:43:19

+0

謝謝Ayesh,但我找不到應用程序選項卡中的outlook msg文件的任何內容。 – Mausami 2013-05-04 11:21:39

+0

@Mausami你是如何在php中創建msg的,我一直在搜索整天沒有運氣的代碼? – Aba 2014-08-20 19:07:21

回答

0
if($ext=="msg") 
    { 
    header("Content-Type: text/Calendar"); 
    header('Content-Disposition: inline; filename='. basename($filename)); 
    echo base64_decode($file); 
    } 
+0

謝謝denish。但它不工作bcoz它以.ics格式打開文件而不是.msg,所以它給出的錯誤是filename.ics不是有效的日曆文件。 msg文件是否有其他內容類型? – Mausami 2013-05-03 00:07:12

1

我有一個幾乎相似的情況,並能夠解決它。 包括下面的標題,它應該工作得很好。

問候

header("Pragma: public"); 
header("Expires: 0"); 
header('Content-Encoding: UTF-8'); 
header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
header("Content-type: application/vnd.ms-outlook;charset=UTF-8"); 
header("Content-Type: application/force-download"); 
header("Content-Type: application/octet-stream"); 
header("Content-Type: application/download");; 
header("Content-Disposition: attachment;filename=test.msg"); 
header("Content-Transfer-Encoding: binary "); 
相關問題