Force web server to download MP3 files instead of streaming them in default media player

Hello Experts!

I'm wondering what change I'd need to make to the MIME types in httpd.conf so that if <a href="song.mp3">Click Here</a> was clicked on a web page, the MP3 would spawn an Open/Save dialog box instead of downloading the song and playing it through my default media player.

Maybe modifying httpd.conf is the wrong approach.  I obviously don't know.  Any solution is welcome.

Your input would be greatly valued and appreciated.  Let me know.  Thanks!

Brendan
brendanwovAsked:
Who is Participating?
 
giltjrConnect With a Mentor Commented:
Ah.  Well, part of the problem is that what to do with the file is generally based on the browser, not necessarily what the server says.

What you can try is follow the instructions at:

     http://elouai.com/force-download.php

which has a PHP script that should force a download.  I have not use this specific script, but I have done things like it.  I just don't have access to my code any more.
0
 
giltjrCommented:
Why not right click and select "Save link as'?
0
 
brendanwovAuthor Commented:
Hey Giltjr!

I'm building an application which distributes (legal) MP3's.  I want to force users of the product to download MP3's.  My target audience won't be sophisticated enough to know to proactively right click and save.

Thanks!

Brendan
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
jonnykeoghCommented:
You could put a MIME configuration in httpd.conf, that set all MP3 files to a different MIME type, then the browser wouldn't see it as an MP3 file, and would ask the user to download it.

    For example:
    AddType application/x-notknown .mp3

That above line should work.


J
0
 
milanmkCommented:
You can put the following code either in .htaccess or httpd.conf.

AddType audio/winamp .mp3

And a link like this <a href="song.mp3">Click Here</a> will give you an Open/Save dialog box.
0
 
jonnykeoghCommented:
milanmk,

That's pretty much what I've just said (use a different MIME type to confuse the browser), and he already knows how to use HTML.


J
0
 
giltjrCommented:
The issue with changing the mime type is that the person downloading is still in charge. I get the pop-up asking me want to do, I know it is a MP3 so I say open with application "X" and make it a permanent change.
0
 
brendanwovAuthor Commented:
Hey Experts!

Thanks for your input on this matter.  giltjr gave me the most complete solution, so I am awarding him the points.  The script he referred me to doesn't quite work perfectly but with some tweaking I think I will get what I want.

Thanks to everyone for their input!

Brendan
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.