Force Download with .htaccess
I've been trying to find a way of force downloading mp3's for an internet radio website and stumbled accross the .htaccess method using:
Header set Content-Disposition attachment
AddType application/octet-stream mp3
Both seem to work fine for most mp3's but for some strange reason not all of them. I had tried renaming the files that dont work with names that do, to no avail and it is not size dependand as some of the files that don't work are smaller than ones that do. As far as I can tell there is no difference between the files that do and do not work and are all in the same folder.
Any ideas anyone....
You're probably using IE. IE attempts to second-guess the server as to the downloaded file's MIME-type. There is, unfortunately, nothing that can be done about this.
Not possible, I'm afraid.
Your best bet is to compress it somehow (gzip, bzip2, zip).
so... downloading as opposed to streaming?
Isn't there some way to make it automatically download?
Not FORCED download... as in they can still type in the url into the address bar, but it would make it default to downloading.
No, I just meant making it open as a download as opposed to a link you can just click and go to. Not sure how to do it... gmail does it with certain filetypes... there's some way, but might be incredibly complex CGI or something, or something more than that.
That'll work, though. Yep.
Hmmm, interesting. Care to elaborate?
No, what the OP originally posted is about the best that can be done from the server.
Originally Posted by djr33
If IE didn't have a complete disregard for the requirements of RFC 2616 (that is, HTTP/1.1), this wouldn't be an issue (and this is the biggest stumbling block). Simply presenting an application/octet-stream Content-Type header value would produce the download prompt. Allowing the user to configure content handling, like Opera and Firefox permit, would result in an even better solution: send an accurate Content-Type header value and act based on user preferences.
I'm afraid there isn't really what you'd consider an adequate solution; trying to force anything on the Web is often a non-starter. Suggestions are about as much as you can hope for, and poor software, like IE, will always limit your options.
I would be happy if I could at least get a dialogue asking the user what they would like to do with the file. There are some instances when you would prefer to stream large mp3's for instance if you just wanted to check out the music without waiting to download but the standard version of Quick Time does not allow you to save the file once it is downloaded.
Any suggestions on how to achieve this?