Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Apr 2006
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    mp3 download in javascript?

    how can I make it so when a person clicks on a link attached to an mp3 file it displays the download dialog allowing them to save it to their harddrive as opposed to just playing the file through quicktime. I need it to be xhtml strict compliant as well.

  • #2
    New Coder
    Join Date
    Sep 2005
    Location
    Latina (Italy)
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts
    There's a way of managing it. But you have to alter the HTTP headers by using PHP, for instance...

    I mean: it's just needed you make the browser open a new window in a Strict-XHTML compliant way (it's easy, there are many threads talking about that in this forum) when the user click the anchor you put into your webpage. The address you have to show must be a page made just for downloading - no XHTML tag into.

    Its headers must be something like this:
    Code:
    Content-type: audio/mpeg;
    Content-Disposition: attachment; filename="yourmp3.mp3"
    Then, it's just needed you put the mp3 file be directly the output, into the HTTP body. And you're gone.
    I said: I know the way to making it in PHP but I suppose it's not the right forum here to speak about this method...

    I hope I've told you useful stuff!


  •  

    Posting Permissions

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