Apache 2 - how to set mp3 to download not play in browser
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Apache 2 - how to set mp3 to download not play in browser
Hey all,
Have apache2 running on RHEL4 and trying to insert links to download mp3s. All i do is <A HREF="song.mp3">DOWNLOAD</A> but when i click on the link, the mp3 plays in the browser. I want to be able to download it.
(possibly have the ability to have a link to download, and a link to play)
Do I need to add something to httpd.conf?
Thanks all.
My browser decides what it does with (most of) the content that is served, based on what the defaults are or what the user sets/unsets. It's generally considered 'easy' to play multimedia/sound directly from the browser (with a plugin, external app or the browser software itself) and most defaults settings will do this.
Thanks for the reply.
I cant figure that one out. I right click on my link, and there is no "save as" option only save link as (I guess this is the same thing). The only thing I can really do I click the link, and it plays in the browser.
If im looking to do this, Do I need to tell people above the link to Right click, and click "save link as"??
You can use the AddType directive to override the MIME type on the server end but you would need to have different file extensions on two different files for them to behave differently. IE doesn't listen to what the server says about mime types anyway, it just goes by what the extension actually is.
Allright, thanks. Ill try adding an application mime type for mp3, and see if that works.
Security question: im trying to use php to authenticate users, and if logged in, then youll be able to download the mp3. Ive tried moving the mp3s to a folder above the document root, but i cant get to it. And id rather not use .htaccess, as i am using mysql and php to authenticate.
Is there a way to say "your only allowed to download this file (mp3) if you are authenticated"??
I wrote a web app a few years ago that did that. I had a directory that was outside of the web directory that held the files and stored the path in the mysql database. There were a few php pear packages required to make it work so that it would handle the mime types correctly and the dtabase correlated certain files with certain users but it worked nice.
The stuff is on a computer at home, I will have to dig it up and I will post the pear packages I used.
Ive tried this, and in order to protect the files, i have to go one directory above the document root of the website. However when I do, i get "Not Found" from the browser.
I used HTTP_Download to send the files from the server. I found that you did have to maintain a mime type column in the database so that the downloads would behave correctly, but that could be used to offer two different behaviors for the same file by just having two lines in the database for each file and referencing them seperately. If you are planning to upload files through the site as well, make sure you grab the mime type at upload.
apologies to the host for the off topic drift here
now back to your regular scheduled linux questions
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.