I sincerely hope I'm asking a stupid question, and that the solution is simple. Here goes:
All the examples I've found for sending files (user downloads a file) involve a method like so:
<?php
$name="filename.mp3"
header("Content-type: audio/x-mpeg");
header("Content-disposition: attachment; filename=filename.mp3");
// Method 1:
fpassthru(fopen("filename.mp3","rb"));
// Method 2:
fread(..);
// Method 3:
readfile(..);
// whatever, etc. (all involve reading the file)
?>
...so the problem is now this - I'm dealing with MP3s. MP3s can be pretty large (>15MBs, etc). The previous three methods all involve PHP 'reading' the entire file. This blows up my httpd processes. ob_start() and ob_end_flush() would sort of solve my problem. However, with heavy server load (multiple users), even though the httpd processes would be mitigated back down to a reasonable size by ob_end_flush(), during actual the 'read file' process, the server load is stil ridiculously high....
...SO, isn't there a way to send a file to a user w/o PHP/Apache reading the whole damn thing first? When you click on a standard HTML hyperlink with URL pointing directly to the file to be downloaded, web servers / backends don't read the entire file before popping up the 'Save/Open' browser dialogue, right?
How do use PHP to send a user an MP3? I'm all ready to go, except I want my server to only read the file as it's streamed to the user, and not read the entire thing, and then send it as stdout.
helphelphelphelp...
Thanks!
-Paul.