[go: nahoru, domu]

Voting

: nine minus five?
(Example: nine)

The Note You're Voting On

flobee at gmail dot com
19 years ago
regarding php5:
i found out that there is already a disscussion @php-dev about readfile() and fpassthru() where only exactly 2 MB will be delivered.

so you may use this on php5 to get lager files
<?php
function readfile_chunked($filename,$retbytes=true) {
$chunksize = 1*(1024*1024); // how many bytes per chunk
$buffer = '';
$cnt =0;
// $handle = fopen($filename, 'rb');
$handle = fopen($filename, 'rb');
if (
$handle === false) {
return
false;
}
while (!
feof($handle)) {
$buffer = fread($handle, $chunksize);
echo
$buffer;
if (
$retbytes) {
$cnt += strlen($buffer);
}
}
$status = fclose($handle);
if (
$retbytes && $status) {
return
$cnt; // return num. bytes delivered like readfile() does.
}
return
$status;

}
?>

<< Back to user notes page

To Top