首页 > 解决方案 > 为什么 adobe reader 在 PHP Content-Dsiposition:attachment 时无法打开文件

问题描述

我正在使用 PHP 在浏览器中显示 PDF 文件。当我使用此代码时:

header('Content-type: application/pdf');
header('Content-Disposition: inline');

一切正常。没问题。

但是当我使用此代码下载相同的文件时:

header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="MyPdfFile.pdf"');

我收到以下错误消息:

adobe reader 无法打开文件,因为它不是受支持的文件类型或文件已损坏。

我不明白具有完全相同信息的同一文件如何出现此问题。我尝试了 Edge 和 Chrome,两者都是一样的。

哈罗德。

标签: phpcontent-disposition

解决方案


推荐阅读