Advanced Search

Page 1 of 4 123 ... LastLast
Results 1 to 10 of 34

Thread: Force Download with .htaccess

  1. #1
    Join Date
    Mar 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Force Download with .htaccess

    Please help!!

    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:

    <Files *.mp3>
    ForceType application/octet-stream
    Header set Content-Disposition attachment
    </Files>

    or simply

    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....

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    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.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Mar 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    What about using Javascript to force download the file? I've seen examples of this on forums but looks more complicated than the .htaccess method.

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Not possible, I'm afraid.
    Your best bet is to compress it somehow (gzip, bzip2, zip).
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,154
    Thanks
    261
    Thanked 690 Times in 678 Posts

    Default

    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.

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    As I said: compress it.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,154
    Thanks
    261
    Thanked 690 Times in 678 Posts

    Default

    Sure.

    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.

  8. #8
    Join Date
    Mar 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hmmm, interesting. Care to elaborate?

  9. #9
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by djr33
    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.
    No, what the OP originally posted is about the best that can be done from the server.

    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.

    Mike

  10. #10
    Join Date
    Mar 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •