Page 1 of 1

download file

Posted: Thu Mar 11, 2004 8:20 am
by naminator2
I dont know whether this is the right place to post this but:

I have a website where in a database all information about certain mp3 files, I let the user search the database and then they can download a song.

I have made it possible to search the database but don't know how to download a file which is from a certain path which is stored in the database.
Could someone give me some example code or explain how to do this.

Thanks

Posted: Thu Mar 11, 2004 8:30 am
by Morpheus
I just don't understand something: The MP3 isn't stored in the DB right? The path to the file is stored in the db and the MP3 sits somewhere on the server, right? :?

Posted: Thu Mar 11, 2004 9:07 am
by naminator2
the file sits on my computer and the db holds the path of the file

Posted: Thu Mar 11, 2004 9:09 am
by Morpheus
Ok, then you would typically echo an html <a href="path/path/path/filename.mp3"></a> where the "path/path/path/filename.mp3" should be referencing the file on your PC. The path should be accessable through your browser. Much like when you try to view an image in a new window.

Posted: Thu Mar 11, 2004 4:49 pm
by tim
how is your table set-up for the db?

Posted: Thu Mar 11, 2004 5:28 pm
by pickle
Investigate how to send headers with PHP. It's possible to change it to octet/stream or something like that, which should trigger a download.

[php_man]header()[/php_man]

Posted: Thu Mar 11, 2004 5:37 pm
by pickle
Investigate how to send headers with PHP. It's possible to change it to octet/stream or something like that, which should trigger a download.

[php_man]header()[/php_man]