Thus Curt Zirzow & I wrote:


header("Content-Type: " . $type); header("Accept-Ranges: bytes");



Becareful sending this header.  The client can get confused and
send special headers requesting a partial file, while also
expecting different results than the whole file.


Which header?  The "Accept-Ranges" header?  Should I just not include it?



header("Content-Length: ".filesize($file));
header("Content-Disposition: attachment; filename=".basename($file).";"); //readfile($file); $fp = fopen($file, 'rb');
$buffer = fread($fp, filesize($file));



You'll be much better off if you use fpassthru here. This fread
could kill you're machine's memory.

Curt



I switched my code to look like this:



/*old code:
fp = fopen($file, 'rb');
$buffer = fread($fp, filesize($file));
fclose($fp);
print $buffer;
exit();                 
*/


$fp = fopen($file, 'rb'); $buffer = fpassthru($fp); fclose($fp); exit();


Yet in IE if I choose to 'open' the file instead of saving it, it asks me that question twice. I'm wondering if that will cause an error on an older version of i.e. or any other browser.


On php.net, it gave this code:
|// open the file in a binary mode
$name = ".\public\dev\img\ok.png";
$fp = fopen($name, 'rb');

// send the right headers
header("Content-Type: image/png");
header("Content-Length: " . filesize($name));

// dump the picture and stop the script
fpassthru($fp);
exit;|



basically the same code, but without an fclose(); could this be doing it?

Best Regards, and thank you so much for the help,

Scott Taylor

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to