hi all!
i wrote a download-script, which copys the files from a non-webserv-directory to stdout (for security reasons):
<pre>
header("content-type: application/stream");
header("content-length: $len");
header("content-disposition: attachment; filename=".basename($filename));
readfile($filename);
</pre>
the problem is: it works fine, but not with files bigger than 8mb (there the download says: 0 bytes downloaded). i corrected the memory-limit in the php.ini, but it didn't work either.
so tried a workaround from "readfile()", cause it seems, readfile loads the whole file at once, and then writes out.
<pre>
$fp = fopen($filename, "rb");
$fpout = fopen('php://stdout', "wb");
header("content-type: application/stream");
header("content-length: $len");
header("content-disposition: attachment; filename=".basename($filename));
while (!(feof($fp)))
{
$stored = fread($fp,1024);
fwrite($fpout, $stored);
}
fclose($fp);
fclose($fpout);
</pre>
now, downloading starts with every file (yeehaa!), but (1) neither the right filename (2) nor the right size is displayed in the download-dialog. and (3) - the downloaded file seems to be corrupt.
whats wrong? is there some problem with using stdout?
thank you,
+ stefan