How can I set the file name for a download link?

Viewed 347

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?

3 Answers

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>
<a href="https://-----/test1.pdf" download="test2.pdf">download </a>

That's all you have to do.

Related