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

Time:10-31

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?

CodePudding user response:

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

  • Related