Php 在浏览器中查看pdf文件,而不是下载

Php 在浏览器中查看pdf文件,而不是下载,php,codeigniter,fpdf,Php,Codeigniter,Fpdf,嗨,朋友们,我有这类代码。我的要求是,我必须在浏览器中显示加载的pdf(在浏览器中打开pdf),但此时pdf下载到硬盘。相反,我想在浏览器中查看文件 您需要将内容配置更改为内联 改变 header("Content-Length: " . filesize ('theme/assets/pdf/ci.pdf' ) ); header("Content-type: application/pdf"); header("Content-disposition: attachment;

嗨,朋友们,我有这类代码。我的要求是,我必须在浏览器中显示加载的pdf(在浏览器中打开pdf),但此时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文件而不是下载的浏览器设置:

在Chrome中打开PDF 在您的计算机上,打开Chrome。 在右上角,单击“更多设置”。 在底部,单击高级。 在“隐私和安全”下,单击内容设置。 在底部附近,单击PDF文档。 关闭下载PDF文件,而不是在Chrome中自动打开它们

Mozilla Firefox中的设置

  • 点击最右边的3行
  • 点击选项
  • 一般选择转到应用程序
  • 将PDF文件设置为“在Firefox中预览”

  • 你在用什么dompdf@AdarshMPallickal不,我没有使用iTunes内联而不是attatchment@AdarshMPallickal是的,非常感谢你的付出和工作guys@AdarshMPallickal你能告诉我如何将这个加载的PDF转换成图像吗
    header("Content-disposition: attachment;     
    filename=".basename('theme/assets/pdf/ci.pdf'));
    
    header("Content-disposition: inline;     
    filename=".basename('theme/assets/pdf/ci.pdf'));