php - 为什么 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,两者都是一样的。
哈罗德。
解决方案
推荐阅读
- excel - Excel VBA 优化宏以将文件转换为 .xlsx 然后 TextToColumns
- javascript - 如何设置基于道具的动画过渡?
- r - R:使用 stl 时出现时间序列错误
- c# - 将 Autofac 与工厂模式一起使用的正确方法?
- batch-file - 在命令行中运行命令有效,在 bat 中无效
- java - SSL 加密:RSA Premaster 密码错误
- javascript - Javascript If false return behaving in unexpected way. Why?
- docker - Hyperledger Docker Container Dependency
- influxdb - InfluxDB 将不同的字段值合并到单个打印输出
- php - Best way to prevent simultaneous login