4

I would like to download an HTML file, let's say test1.pdf. Here's what I have right now:

<a href="https://-----/test1.pdf" download>download </a>

How can I make it so that it can download as test2.pdf?

isherwood
  • 58,414
  • 16
  • 114
  • 157
  • 1
    Is that just a static file or do you have some server logic behind it? You can give alternate download filenames with a Content-Disposition header, but probably not just configuring it in HTML. – Rup Oct 07 '20 at 19:52
  • https://stackoverflow.com/questions/3802510/force-to-open-save-as-popup-open-at-text-link-click-for-pdf-in-html – Bernhard Oct 07 '20 at 19:55
  • Does this answer your question? [Force to open "Save As..." popup open at text link click for PDF in HTML](https://stackoverflow.com/questions/3802510/force-to-open-save-as-popup-open-at-text-link-click-for-pdf-in-html) – Bernhard Oct 07 '20 at 19:55
  • Does this answer your question? [How can I create download link in HTML?](https://stackoverflow.com/questions/2793751/how-can-i-create-download-link-in-html) – sanoj lawrence Oct 07 '20 at 19:58

3 Answers3

5

You can suggest a filename for the browser to use when saving the file in the value of the download attribute.

<a href="https://-----/test1.pdf" download="test2.pdf">download </a>
D. Pardal
  • 6,173
  • 1
  • 17
  • 37
1

Try something like this. The download load attribute specify its a download and not a link.

https://www.w3schools.com/tags/att_a_download.asp

<a href="/images/myw3schoolsimage.jpg" download="w3logo">
sanoj lawrence
  • 951
  • 5
  • 29
  • 69
0
<a href="https://-----/test1.pdf" download="test2.pdf">download </a>

That's all you have to do.