0

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.

Wolf Cat
  • 171
  • 1
  • 3
  • 18
  • possible duplicate of [(HTML) Download a PDF file instead of opening them in browser when clicked](http://stackoverflow.com/questions/6794255/html-download-a-pdf-file-instead-of-opening-them-in-browser-when-clicked) – Dryden Long Jan 23 '14 at 22:30

2 Answers2

1

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:

chasepeeler
  • 137
  • 8
0

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.

Anhong
  • 232
  • 3
  • 10