0

this is my code which i am writing in render method, which works fine, but instead of downloading this file it's opening in browser.

<a href="http://www.sites/default/files/2019-01/560_12thMarkSheet.pdf" target="_blank" type="application/pdf; download='some_pdf_name'> length=362340">download</a>

How can i give a link in react to force download a file, file which is coming from external server.

mks
  • 351
  • 1
  • 3
  • 16
  • 2
    Possible duplicate of [How to make PDF file downloadable in HTML link?](https://stackoverflow.com/questions/364946/how-to-make-pdf-file-downloadable-in-html-link) – 2pha Feb 04 '19 at 06:56

2 Answers2

1

HTML5

<a download href="file.pdf">Download PDF</a> 
Tính Ngô Quang
  • 4,400
  • 1
  • 33
  • 33
0

Suppose you have a variable names as "link" in which the link is stored. So you can do,

    <a href={`${link}`} type="application/pdf; download='some_pdf_name'>Download</a>
Mayank Bansal
  • 1,755
  • 2
  • 9
  • 22
  • this is opening a file (a pdf file) in browser, instead i want it to force download it. – mks Feb 05 '19 at 14:20