note 108129 deleted from function.readfile by joey
| From: | joey@php.net | Date: | Mon, 21 Jan 2013 10:01:18 +0000 |
| Subject: | note 108129 deleted from function.readfile by joey | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-193290@lists.php.net to get a copy of this message | ||
Note Submitter: stefano dot cudini at gmail dot com
----
readfile with accurate limit rate, using pv linux command
<?php
$file = $_SERVER['QUERY_STRING'];
header("Content-length: ".filesize($file));
header("Content-type: ".mime_content_type($file));
readfileLimit($file);
function readfileLimit($file, $limit='10M')
{
$f = popen("pv -L $limit '$file'",'r') or return false;
while(!feof($f))
{
echo fread($f, 1024);
flush();
}
fclose($f);
}
?>