www.webdeveloper.com
Results 1 to 9 of 9

Thread: Writing code for downloading MP3 files

  1. #1
    Join Date
    Apr 2008
    Posts
    136

    Writing code for downloading MP3 files

    Hello,

    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.

    Any thoughts?

  2. #2
    Join Date
    May 2004
    Location
    FL
    Posts
    3,453
    What languages do you have available? What kind of a server is it, Apache Windows?

  3. #3
    Join Date
    May 2008
    Posts
    4
    I too would like to know. I am writing in html and have a child's understanding in CSS and Javascript but can figure that out.

    I saw another webhosting site that had ?action=save at the end of the url but that didn't work for me. I suspect that was not html.

    edited to add that I am hosting on Yahoo small business but have access to several html editors and notepad.

  4. #4
    Join Date
    Feb 2007
    Location
    New Zealand
    Posts
    190
    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.

  5. #5
    Join Date
    Feb 2008
    Location
    NW Washington State
    Posts
    1,856
    Could you accomplish this with PHP? If so, how would that be done?
    Thanks!
    Eye for Video
    www.cidigitalmedia.com

  6. #6
    Join Date
    May 2008
    Posts
    4
    Quote Originally Posted by toenailsin
    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.

    thank you

  7. #7
    Join Date
    May 2008
    Posts
    4
    bump

  8. #8
    Join Date
    May 2004
    Location
    FL
    Posts
    3,453
    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.

  9. #9
    Join Date
    May 2008
    Posts
    4
    Quote Originally Posted by LeeU
    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.

    Is that something I can do?

    thank you

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles