I maintain a website that contains audio files that users can listen to simply buy clicking on a built in audio player on the website. However, I'd like to give the users the option of downloading a copy of the mp3 file to their computer so they can listen to it offline.
How do I write the code so that when the user clicks on the link I provided, it will prompt them to do that. I can't just do <a href="MP3file.mp3">MP3 file</a>, because that will just open the file and these are rather large files (15-20MB), so that would take a while to load.
a server-side language is required to send the header:
('Content-Type: application/octet-stream')
this forces the browser to download it the file.
or you can edit the config files of the server, and define that header as the default for that filetype.
I don't have access to the server side. is there a code that can be placed individually on the anchor? either in css, JS, or html? I don't know PHP yet.
If you don't have access to the server, your best bet would be to just put a note for them to right-click, etc. to download the file.
I did that for the time being. Maybe I'm not saying it right because I don't exactly know what "having access to the server" means but I did notice when I was having my files hosted on MediaMax that under the hosting side the url had a " ?action=save" code at the end.
Bookmarks