maca
maca

Reputation: 540

How can I change the name of the file that will download?

I have a link

<a href="/media/maca.pdf" download=""><img src="/static/images/download.svg" alt=""></a>

When I click download it starts downloading with the name maca.pdf. But I want to change that.

Can I achieve that?

Upvotes: 1

Views: 81

Answers (1)

ConnerWithAnE
ConnerWithAnE

Reputation: 1158

You just simply need to have that name in the download="". So if you wanted to name the file myFile.pdf then you would do

<a href="/media/maca.pdf" download="myFile"><img src="/static/images/download.svg" alt=""></a>

Now when you click download the file should be called myFile.pdf

So after looking around it seems it is because your file is coming from a different location. Check out this link Download attribute with a file name not working? and this one Create a Downloadable Link using HTML5 Download Attribute

Upvotes: 2

Related Questions