1

firefox 每次都提示下载 PDF 文件,但 Chrome 在浏览器中显示 PDF 而没有下载提示,但我需要在任何浏览器中显示 PDF 而没有下载提示,有人可以帮我吗?

这是代码

$file = 'the_pdf.pdf';


header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="' . $file . '"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($file));
header('Accept-Ranges: bytes');

@readfile($file);
4

2 回答 2

0

"show PDF in any browser": You can't, since most browser allow to override the inline display of plugins via some setting. My Opera for example always opens PDF-links with a download dialog. A web-developer can't do anything about this. And this is intended.

于 2012-07-04T10:10:50.313 回答
0

这将基于插件。如果浏览器不知道如何打开文件,则会提示下载。

于 2012-07-04T10:09:01.623 回答