在浏览器中使用php显示.msg文件

问题描述:

我在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

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

我有一个几乎相似的情况,并能够解决它。 包括下面的标题,它应该工作得很好。

问候

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 ");