note 83653 added to function.readfile
| From: | yura_imbp at mail dot ru | Date: | Fri, 06 Jun 2008 04:46:40 +0000 |
| Subject: | note 83653 added to function.readfile | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-140163@lists.php.net to get a copy of this message | ||
if you need to limit download rate, use this code
<?php
$local_file = 'file.zip';
$download_file = 'name.zip';
// set the download rate limit (=> 20,5 kb/s)
$download_rate = 20.5;
if(file_exists($local_file) && is_file($local_file))
{
header('Cache-control: private');
header('Content-Type: application/octet-stream');
header('Content-Length: '.filesize($local_file));
header('Content-Disposition: filename='.$download_file);
flush();
$file = fopen($local_file, "r");
while(!feof($file))
{
// send the current file part to the browser
print fread($file, round($download_rate * 1024));
// flush the content to the browser
flush();
// sleep one second
sleep(1);
}
fclose($file);}
else {
die('Error: The file '.$local_file.' does not exist!');
}
?>
----
Server IP: 195.54.192.44
Probable Submitter: 127.0.0.1
----
Manual Page -- http://www.php.net/manual/en/function.readfile.php
Edit -- https://master.php.net/note/edit/83653
Del: integrated -- https://master.php.net/note/delete/83653/integrated
Del: useless -- https://master.php.net/note/delete/83653/useless
Del: bad code -- https://master.php.net/note/delete/83653/bad+code
Del: spam -- https://master.php.net/note/delete/83653/spam
Del: non-english -- https://master.php.net/note/delete/83653/non-english
Del: in docs -- https://master.php.net/note/delete/83653/in+docs
Del: other reasons-- https://master.php.net/note/delete/83653
Reject -- https://master.php.net/note/reject/83653
Search -- https://master.php.net/manage/user-notes.php