Intra Intra - 5 days ago 6
HTML Question

Change name of download in javascript

If a user clicks on a downloadable link such as

<a href="downloadable.txt">Download</a>


Is there a client-side (html or javascript) way to change the name of the file before the 'Save As' dialog?

Answer

No, you cannot change this from the client side (HTML or javascript). You need to change it from the server. One way is to use a server side script which will set the Content-Disposition HTTP response header:

Content-Disposition: attachment; filename=somecustomname.txt
Comments