Robin Getz wrote:
The issue is that readfile writes it to the output buffer before sending it to the client.

Are you sure you HAVE output buffering? What does ob_get_level() return? If it returns 0 then you don't have output buffering.

My theory (and it's only a theory) is, that readfile may not be the optimal function for this task. Maybe it's implemented to read the whole file into memory and then output the data, don't know.

If this theory is true, you may try fpassthru(). The name of this function sounds like the file is just "passed through" which sounds like the task you want to perform :-)

The example on php.net of this function is exactly matching your task:

<?php

// 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;

?>

--
Bye, K <http://www.ailis.de/~k/> (FidoNet: 2:240/2188.18)
[A735 47EC D87B 1F15 C1E9  53D3 AA03 6173 A723 E391]
(Finger [EMAIL PROTECTED] to get public key)

Attachment: signature.asc
Description: OpenPGP digital signature



Reply via email to