PHP File download with speed limit
PHP snippetsを眺めていたら、速度制限付きのダウンロードを実現するものが。
[php]
$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);
}
[/php]
制限分を読み込んで、出して、待つ、という形なんですね。なるほどーと思った例でした。