1
<a href="original_filename.pdf">Download this file</a>

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

I'm hoping for a client-side solution.

Intra
  • 2,089
  • 3
  • 19
  • 23

4 Answers4

4

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.

nickf
  • 537,072
  • 198
  • 649
  • 721
1

Solved in duplicate question.

Content-Disposition: attachment; filename=somecustomname.txt
Community
  • 1
  • 1
Intra
  • 2,089
  • 3
  • 19
  • 23
0

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

Koen Peters
  • 12,798
  • 6
  • 36
  • 59
0

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.

Armatus
  • 2,206
  • 17
  • 28
  • This was my thinking, except for the gain ;) – Intra Apr 05 '12 at 23:22
  • It's true that it could exist though. I mean, you can have a `mailto:x@x.x?subject=Whatever%20I%20Want` so why not something like `dl:file.pdf?name=Actually_call_it_this.pdf` :) – Armatus Apr 05 '12 at 23:30