如何自动停止在 iframe 中下载 PDF 而是查看文件?

Sam*_*Sam 5 html javascript php pdf iframe

我的网站上有一个加载 PDF 文件的 iframe:

<iframe src="file.pdf" frameborder="0" width="800" height="600"></iframe>
Run Code Online (Sandbox Code Playgroud)

但是它是自动下载的,我想查看文件而不是下载它。

那么我该如何解决这个问题呢?

Jan*_*lik -1

您需要告诉您的服务器将该文件作为 application/pdf(“PDF”)发送

...

额外花絮:
- 为什么网站上有 PDF?您显示 PDF 的网页已经显示了 PDF 文件显示的内容
- 为什么要在 iframe/等中加载 PDF。如果您只想下载它?为什么不直接链接到它