PHP File download with speed limit

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]

制限分を読み込んで、出して、待つ、という形なんですね。なるほどーと思った例でした。

関連する記事:

Powered by

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">