download file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
naminator2
Forum Newbie
Posts: 3
Joined: Thu Mar 11, 2004 8:20 am

download file

Post 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
Morpheus
Forum Newbie
Posts: 6
Joined: Thu Mar 11, 2004 7:00 am
Location: South Africa

Post 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? :?
naminator2
Forum Newbie
Posts: 3
Joined: Thu Mar 11, 2004 8:20 am

Post by naminator2 »

the file sits on my computer and the db holds the path of the file
Morpheus
Forum Newbie
Posts: 6
Joined: Thu Mar 11, 2004 7:00 am
Location: South Africa

Post 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.
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

how is your table set-up for the db?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post 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]
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post 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]
Post Reply