在浏览器中查看pdf文件,而不是下载 [英] View pdf file in browser instead of downloading

查看:196
本文介绍了在浏览器中查看pdf文件,而不是下载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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已下载到硬盘上。相反,我想在浏览器中查看文件。

Hi friends i've code of this type. my requirement is i've to display the loaded pdf(open the pdf in browser) in browser but where as now the pdf is downloaded to hard disk . instead I would like to view the file in browser .

推荐答案

您需要将 Content-disposition 更改为内联

更改

header("Content-disposition: attachment;     
filename=".basename('theme/assets/pdf/ci.pdf'));

收件人:

header("Content-disposition: inline;     
filename=".basename('theme/assets/pdf/ci.pdf'));

这篇关于在浏览器中查看pdf文件,而不是下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆