0

HTML5 has a convenient download attribute that allows the downloading of a file named foo.exe to be saved as a different name like bar.exe:

<a href="http://example.com/foo.exe" download="bar.exe">Download It</a>

However, support is limited to recent versions of Chrome and Firefox. I plan to use this for those browsers, but use Downloadify for various IE versions.

Most of the Downloadify examples that I've seen are regarding the saving of textual data from the client. Is it possible to use Downloadify with binary files from a known URL?

putvande
  • 15,068
  • 3
  • 34
  • 50
Bullines
  • 5,626
  • 6
  • 53
  • 93

1 Answers1

1

As a suggestion, you don't need to use something like Downloadify if you all you are trying to do is get the browser to prompt the user to download with a specific name. The HTML5 method is a good way to go but as you say, support is limited. The other "traditional" way of doing this is to use the Content-Disposition HTTP header. For example, if you are using Apache, you can put something like this in your .htaccess file:

<LocationMatch "/path/to/foo.exe">
    Header set "Content-disposition" "attachment; filename=bar.exe"
</LocationMatch>

That causes the Content-Disposition header to be set as "attachment", which causes the browser to download instead of view directly, and you can specify the suggested file name for the user as well.

Brad Peabody
  • 10,917
  • 9
  • 44
  • 63