在IE中保存PHP的PDF输出


saving pdf output from php in IE

我正在使用tcpdf通过php生成pdf文件,并且我相应地设置了标题,以便在浏览器中打开php文件时,它显示为pdf。

现在在另一个页面中,我有一个指向此php文件的超链接,而在Firefox中,当有人右键单击此链接并使用"另存为"时,该文件将另存为pdf文档。然而,在IE上,它保存与包含垃圾值(pdf编码内容)的php文件扩展名。IE有什么方法可以将php识别为pdf文档吗?

确保你使用的是

header('Content-type: application/pdf')

在您的输出中。

确保设置以下标头:

header("Content-type: application-download");
header("Content-Length: $size");
header("Content-Disposition: attachment; filename=MyPDF.pdf");
header("Content-Transfer-Encoding: binary");