Reputation: 171
I have the following link:
<a href="pdf/rental-application.pdf"><img src="images/button-download-rental-application.jpg" width="348" height="50" alt="Download Rental Application"></a>
However, sometimes it downloads the PDF and sometimes it opens it in the browser window.
I need it to always download.
I'm on a linux server using .html pages.
Thanks.
Upvotes: 0
Views: 119
Reputation: 137
If you are using apache, try this in your config file (or a .htaccess)
<FilesMatch "\.pdf$">
Header set Content-Disposition attachment
</FilesMatch>
The download attribute will work, but it's HTML5 specific, and I believe only works in firefox and chrome at the moment. If you do use the download attribute though, you should actually do it like this:
Upvotes: 1
Reputation: 232
This should work:
<a href="pdf/rental-application.pdf" download><img src="images/button-download-rental-application.jpg" width="348" height="50" alt="Download Rental Application"></a>
Just add a download in the tag.
Upvotes: 0