* Thus wrote Scott Taylor: > > 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?
Correct. That header will tell the client that you're willing to send the file to them from where ever they want, instead of the beginning of the file. > > > > >> 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. > > ... > > $fp = fopen($file, 'rb'); > $buffer = fpassthru($fp); > fclose($fp); > exit(); To be safe, check to be sure that $fp is valid and see if there was an error with fpassthru: if ($fp) { $sent = fpassthru($fp); if ($sent === false) { // there was an error } fclose($fp); } > > 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. I've had the double question problem a while back, but unfortantly I dont recall what the problem was. I usually tend to just 'Save' things because I don't generally like the browser opening things for me :) Although, In the real world, people proably tend to open things (hence all their viruses). But besides all my lecturing... It could be possible to send an inline file instead: Content-Disposition: inline; filename="yadayada"; > 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? That example code is bad. The most suspect thing is the Content-disposition header. Curt -- First, let me assure you that this is not one of those shady pyramid schemes you've been hearing about. No, sir. Our model is the trapezoid! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php