Change name of download in javascript

HTML5 provides the a[download] attribute which lets you rename a file. This example will download link.txt and rename it something.txt.

​<a download="something.txt" href="https://stackoverflow.com/questions/10049259/link.txt">asdf</a>​​​​​​​​​​​​​​​​​​​​​​​​​​​

Note that this only works on same-origin URLs (i.e. not across different domains).

Leave a Comment