-2
<a href="test.pdf" download target="_blank">download PDF file</a>

I want to download this file instead of opening in browser. Whenever I click on it it shows me test.pdf, but now downloading.

And one more thing that how to download file through JavaScript.

halfer
  • 19,824
  • 17
  • 99
  • 186
neha910
  • 199
  • 3
  • 12
  • 3
    http://stackoverflow.com/questions/3749231/download-file-using-javascript-jquery – user2085143 Dec 09 '16 at 10:41
  • 4
    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) – hatef Dec 09 '16 at 10:44
  • problem maybe with the path of your test.pdf – abhit Dec 09 '16 at 10:44

1 Answers1

0

<a href="/file/path/here.pdf" download >Download PDF</a>

This is possible in HTML5 by using the download attribute. Why do you need to use JavaScript?

More info here.

Ryan Gee
  • 394
  • 1
  • 9