header("Content-Length: " . filesize ('theme/assets/pdf/ci.pdf' ) );
header("Content-type: application/pdf");
header("Content-disposition: attachment;
filename=".basename('theme/assets/pdf/ci.pdf'));
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
$filepath = readfile('theme/assets/pdf/ci.pdf');
嗨,朋友,我有这种类型的代码。我的要求是我必须在浏览器中显示已加载的pdf(在浏览器中打开pdf),但是现在pdf已下载到硬盘上。相反,我想在浏览器中查看文件。
您需要将更Content-disposition
改为inline
。
更改
header("Content-disposition: attachment;
filename=".basename('theme/assets/pdf/ci.pdf'));
至:
header("Content-disposition: inline;
filename=".basename('theme/assets/pdf/ci.pdf'));
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句