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.
Related Topics
PHP: File Download Script
Tutorial | 0 Comments
HTACCESS: Force Download of specific File Types
Tutorial | 0 Comments
XAMPP: How to set up SSL/HTTPS for local Projects
Tutorial | 4 Comments
jQuery: Detect Browser (Browser Switch)
Info | 2 Comments
Windows Batch Script: Computer Shutdown
Tutorial | 2 Comments
Adobe Reader would like to save changes to PDF although nothing was changed
Question | 1 Answer
Reload Images, CSS, JS and Web Pages despite Browser Cache
Tip | 2 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.
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