Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

How to make the user to download a MIDI file

Hi folks,
I am designing a web project(for music) in which we make the
user to download songs they like(all are MIDI files.)
What happen is when i give a link to the song like
"http:/Tamil/Jeans/columbus.mid"
the song started playing in the background.What i wanted when the user clicks the link, it prompts the user to download the song.I don't know how to do it.I am thankful if anyone directs me in right path.

Can anyone help????????????????????

Thanxxxx in advance

Comments

  • aaronjones3593aaronjones3593 Member Posts: 122
    : Hi folks,
    : I am designing a web project(for music) in which we make the
    : user to download songs they like(all are MIDI files.)
    : What happen is when i give a link to the song like
    : "http:/Tamil/Jeans/columbus.mid"
    : the song started playing in the background.What i wanted when the user clicks the link, it prompts the user to download the song.I don't know how to do it.I am thankful if anyone directs me in right path.
    :
    : Can anyone help????????????????????
    :
    : Thanxxxx in advance
    :

    Try this:
    [code]
    columbus.mid
    [/code]
  • jesusjams777jesusjams777 Member Posts: 2
    : : Hi folks,
    : : I am designing a web project(for music) in which we make the
    : : user to download songs they like(all are MIDI files.)
    : : What happen is when i give a link to the song like
    : : "http:/Tamil/Jeans/columbus.mid"
    : : the song started playing in the background.What i wanted when the user clicks the link, it prompts the user to download the song.I don't know how to do it.I am thankful if anyone directs me in right path.
    : :
    : : Can anyone help????????????????????
    : :
    : : Thanxxxx in advance
    : :
    :
    : Try this:
    : [code]
    : columbus.mid
    : [/code]
    :

    Hey I have the same question and I have been trying to figure this out for awhile now. Im trying to create two different kinds of links. One that when you click on it it links directly to the file and opens the audio file in your default player. (That one is easy and i got it) and the other link (not as easy) when you click on it it pulls up a dialogue box asking you if you want to download the mp3 file.

    Can anyone PLEASE help with this. Ive noticed most sites that have this are using either asp or php to make this happen. Any info would be sooo helpfull.

    here are some examples of sites that are doing this.
    http://www.sermonaudio.com/main.asp
    http://www.bible-sermons.org.uk/
    http://www.download.com/ click on music
  • ManningManning Member Posts: 1,621
    : Hey I have the same question and I have been trying to figure this out for awhile now. Im trying to create two different kinds of links. One that when you click on it it links directly to the file and opens the audio file in your default player. (That one is easy and i got it) and the other link (not as easy) when you click on it it pulls up a dialogue box asking you if you want to download the mp3 file.
    :
    : Can anyone PLEASE help with this. Ive noticed most sites that have this are using either asp or php to make this happen. Any info would be sooo helpfull.


    As far as I know, using something like ASP or PHP is the only option. The way they do it (well the way I know of anyway) is to pass the filename you want to download as a parameter to a script. This script reads the file and writes out the binary data. The "trick" is that they can set the content-disposition header to "attachment", which tells the browser to show the open/save dialog.

    If your site has the ability to run ASP or PHP scripts, search for content-disposition on Google and you should find some examples. If you can only do HTML, then I think you're out of luck.
  • jesusjams777jesusjams777 Member Posts: 2
    : : Hey I have the same question and I have been trying to figure this out for awhile now. Im trying to create two different kinds of links. One that when you click on it it links directly to the file and opens the audio file in your default player. (That one is easy and i got it) and the other link (not as easy) when you click on it it pulls up a dialogue box asking you if you want to download the mp3 file.
    : :
    : : Can anyone PLEASE help with this. Ive noticed most sites that have this are using either asp or php to make this happen. Any info would be sooo helpfull.
    :
    :
    : As far as I know, using something like ASP or PHP is the only option. The way they do it (well the way I know of anyway) is to pass the filename you want to download as a parameter to a script. This script reads the file and writes out the binary data. The "trick" is that they can set the content-disposition header to "attachment", which tells the browser to show the open/save dialog.
    :
    : If your site has the ability to run ASP or PHP scripts, search for content-disposition on Google and you should find some examples. If you can only do HTML, then I think you're out of luck.
    :

    THANK YOU! THANK YOU! THANK YOU!
    I was able to search and after a few hours of twisting and turning I figured it out! Thank you for the keywords "content-disposition" also I will note that adding "Force Download" and "mp3" helped.
    Here is a link to a code that worked for me. http://lists.evolt.org/archive/Week-of-Mon-20020513/112746.html

    also for anyone wanting to know how to do this. here is the code I found that works.

    If you can use PHP, you can do this through the header() function - you
    would pass $file to a page containing the code below - e.g.

    In your HTML use this

    download foobar

    the PHP code in download.php :

    <?php

    urlencode($file) ."";',1000);";

    $f = @fopen($file,"r");
    if (!$f)
    print "<HTML>Failed to download $file";
    else
    {
    header("Content-Type: application/octet-stream");
    header("Content-Length: ".filesize($file));
    header("Content-Disposition: attachment; filename=" .basename($file));
    $data="";
    while (!feof($f)) $data.=fread($f,64000);
    fclose($f);
    print $data;
    }
    ?>

    God Bless!!
Sign In or Register to comment.