Jump to content

php header vs. readfile - bandwidth


David Nelson

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/106243-php-header-vs-readfile-bandwidth/
Share on other sites

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.