Force download through markup or JS

Posted by mschoening on Stack Overflow See other posts from Stack Overflow or by mschoening
Published on 2010-02-01T11:29:48Z Indexed on 2010/06/02 17:14 UTC
Read the original article Hit count: 149

Filed under:
|
|
|

Lets assume I have a file on a CDN (Cloud Files from Rackspace) and a static html page with a link to that file. Is there any way I can force download this file (to prevent it from opening in the browser -- for mp3s for example)?

We could make our server read the file and set the corresponding header to:

header("Content-Type: application/force-download")

but we have about 5 million downloads per month so we would rather let the CDN take care of that.

Any ideas?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about html