0

我已经在 ftp 服务器上上传了一个 pdf 文件。以下链接在浏览器中打开 pdf 文件。

http://aptform.culinarysuperstars.com/Appointment_static.pdf

如何为pdf文件创建链接,以便直接下载而不是在浏览器中打开?

4

2 回答 2

0

这是您无法真正控制的,它基于浏览器/用户设置。

如果可以,您可以尝试发送Content-disposition: attachment; filename="Appointment_static.pdf"带有文件内容的标头,这可能会触发下载对话框,而不是在浏览器中显示文件,但您不能真正依赖它。

于 2013-07-23T11:31:24.757 回答
0

在您的 FTP 服务器上找到.htaccess-file。这通常是隐藏的,因此您可能必须确保可以查看和编辑隐藏文件。然后,您可以对其进行修改以强制下载而不是显示在浏览器中。

在文件中包含以下内容:

AddType application/octet-stream .pdf

我不确定这是否适用于任何浏览器;.htaccess如果没有,请在-file中尝试以下操作:

<FilesMatch "\.(?i:pdf)$">
      ForceType application/octet-stream
      Header set Content-Disposition attachment
</FilesMatch>

方法二:

<FilesMatch "\.(pdf)$" >
    ForceType application/octet-stream
    Header add Content-Disposition "attachment"
</FilesMatch>
于 2013-07-23T11:41:04.607 回答