00 Votes

Force PDF Download (not open in Browser)

Question by WebHorn | 2014-09-15 at 19:26

I would like to provide some PDF documents in the download section of my website. When linking the corresponding files directly in HTML (using "a href"-links), the file is always opened in the browser directly instead of that a download is started.

Is there any possibility to force the browser to download a file instead of opening it? If possible, I would prefer a general solution that is not only working for PDFs but also for other file formats.

ReplyPositiveNegative
0Best Answer0 Votes

To ensure, that the browser is offering a file to download instead of displaying it, we have to change the header which our server is sending to the requesting browser together with the file.

There are several possibilities for that:

Perhaps, the HTACCESS solution is a bit simpler, while the PHP solution offers more options for adaptation. Have a look at both solutions to see which way is fitting better in your case.
2014-09-16 at 23:41

ReplyPositive Negative
Reply

Related Topics

PHP: File Download Script

Tutorial | 0 Comments

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own article on askingbox.com. That’s how it’s done.