jane_prg Posted April 17, 2007 Share Posted April 17, 2007 Hello.How are You? I'm wondering about how to setup an mp3 for downloading from my server using php. Should I use something like a filesystem object to convert the data to byte data? I'm at a bit of a loss right now.A tutorial would be helpfull. Thank you Link to comment https://forums.phpfreaks.com/topic/47441-downloading-mp3s/ Share on other sites More sharing options...
Lumio Posted April 17, 2007 Share Posted April 17, 2007 Thanks! I'm fine Hmm... you don't need to use php to download a mp3. Why do you want to use it? But you can change the Header by header() and change the Content-type to audio/mpeg Then you can read the file by readfile(). You're welcome Link to comment https://forums.phpfreaks.com/topic/47441-downloading-mp3s/#findComment-231495 Share on other sites More sharing options...
jane_prg Posted April 20, 2007 Author Share Posted April 20, 2007 Thanks for the reply. I ran this code on an apache server on my machine and it downloaded just fine. The thing is I got a "page can't be displayed error "when I tried to download from a real webserver.It didn't work at all.I'm wondering,perhaps I don't have permission to download.I don't know what the problem is.Any suggestions? Any help at all would be appreciated. <?php header("content-type:application/octet-stream"); header('content-Disposition:attachment;filename="Dark night.mp3"'); readfile('YourSmile.mp3'); ?> Link to comment https://forums.phpfreaks.com/topic/47441-downloading-mp3s/#findComment-233765 Share on other sites More sharing options...
neel_basu Posted April 20, 2007 Share Posted April 20, 2007 <?php header('Content-Type: application/octet-stream'); echo readfile('YourSmile.mp3'); ?> Link to comment https://forums.phpfreaks.com/topic/47441-downloading-mp3s/#findComment-234204 Share on other sites More sharing options...
Lumio Posted April 20, 2007 Share Posted April 20, 2007 readfile echos it automatically. Link to comment https://forums.phpfreaks.com/topic/47441-downloading-mp3s/#findComment-234216 Share on other sites More sharing options...
neel_basu Posted April 20, 2007 Share Posted April 20, 2007 It doesn't echos What it does is addes it to the output Buffer. thats makes it to do something like echo. Link to comment https://forums.phpfreaks.com/topic/47441-downloading-mp3s/#findComment-234218 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.