Skip to content Skip to sidebar Skip to footer

Changing The Name Of An Html Download

Download this file Will save the filename as original_filename.pdf. What if I want the file to be renamed before the download? I'm

Solution 1:

The HTML5 spec allows for setting an attribute on the link called "download".

http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#attr-hyperlink-download

The download attribute, if present, indicates that the author intends the hyperlink to be used for downloading a resource. The attribute may have a value; the value, if any, specifies the default file name that the author recommends for use in labeling the resource in a local file system. There are no restrictions on allowed values, but authors are cautioned that most file systems have limitations with regard to what punctuation is supported in file names, and user agents are likely to adjust file names accordingly.

Solution 2:

Solved in duplicate question.

Content-Disposition: attachment; filename=somecustomname.txt

Solution 3:

I do not think this is possible easily. You can rename the file after it has been downloaded of course.

Solution 4:

Apart from renaming it on the server or telling people to right-click and choose "Save As", the only thing I can think of is to create a temporary copy which you offer for download under a different name. A huge effort with nothing really gained.

Post a Comment for "Changing The Name Of An Html Download"