David Nelson Posted May 19, 2008 Share Posted May 19, 2008 Hi guys, On my site I use php header() functions to force downloading of .mp3 files to bypass Quicktime playing them in-browser -- the MP3 files aren't stored on my server. Now, if I just link to the MP3 and instruct them to "Save target as..." to download it, it takes none of my bandwidth, since it's on a different server, whereas if I use php header() inside of a get.php-type file to make it automatically popup a "save file" dialog, it hogs my server's bandwidth like crazy when people download! So php headers has to pipe the file through the server to the user? Either way, I can't afford this bandwidth so will just a php readfile() funct. like readfile($song->url); NOT take from my bandwidth, as opposed to; header("Content-Length: " . $song->content->length); header("Content-Type: " . $song->content->type); header("Content-Disposition: " . $song->content->disposition); Thanks guys! This forum is very very helpful and the users are friendly. David Quote Link to comment https://forums.phpfreaks.com/topic/106243-php-header-vs-readfile-bandwidth/ Share on other sites More sharing options...
MadTechie Posted May 19, 2008 Share Posted May 19, 2008 did i miss the question ??? why not have another script on the remote server to do the downloads ? have you tried this header "Content-Disposition: attachment; filename=\"http://blar.com/myfile.mp3\""; Quote Link to comment https://forums.phpfreaks.com/topic/106243-php-header-vs-readfile-bandwidth/#findComment-544534 Share on other sites More sharing options...
corbin Posted May 19, 2008 Share Posted May 19, 2008 Using other sites bandwidth is sleazy. Anything your server outputs will use your bandwidth. If you want to steal from the other site, you will have to redirect your users to the other site. Quote Link to comment https://forums.phpfreaks.com/topic/106243-php-header-vs-readfile-bandwidth/#findComment-544563 Share on other sites More sharing options...
Daniel0 Posted May 19, 2008 Share Posted May 19, 2008 Either way, I can't afford this bandwidth so will just a php readfile() funct. like readfile($song->url); That will use twice as much bandwith. First your server will download it from the remote server, then it will upload it to the client requesting it. Quote Link to comment https://forums.phpfreaks.com/topic/106243-php-header-vs-readfile-bandwidth/#findComment-544693 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.