0 0 Votes

Force PDF Download (not open in Browser)

Question by WebHorn | 15/09/2014 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

Computer Expert

Show Profile | Message
Avatar
0Best Answer
0 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.
16/09/2014 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 articles on askingbox.com. How to do.