简体   繁体   中英

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

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?

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>

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

That's all you have to do.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM