色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

php實現下載限制速度示例分享

復制代碼 代碼如下:
// local file that should be send to the client
$local_file = 'test-file.zip';

// filename that the user gets as default
$download_file = 'your-download-name.zip';

// set the download rate limit (=> 20,5 kb/s)
$download_rate = 20.5;

if(file_exists($local_file) && is_file($local_file)) {

 // send headers
 header('Cache-control: private');
 header('Content-Type: application/octet-stream');
 header('Content-Length: '.filesize($local_file));
 header('Content-Disposition: filename='.$download_file);

 // flush content
 flush();

 // open file stream
 $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);
 }

 // close file stream
 fclose($file);

}

else {
 die('Error: The file '.$local_file.' does not exist!');
}

php技術php實現下載限制速度示例分享,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 新邵县| 湖南省| 托里县| 连云港市| 阿巴嘎旗| 华亭县| 连城县| 周至县| 宝鸡市| 泸西县| 抚宁县| 邯郸县| 博白县| 黄大仙区| 定边县| 错那县| 资中县| 云龙县| 江津市| 宁都县| 泽库县| 依安县| 新绛县| 鱼台县| 新河县| 龙岩市| 平原县| 皮山县| 博兴县| 邻水| 正安县| 申扎县| 阳泉市| 五原县| 锡林郭勒盟| 闻喜县| 兰坪| 新巴尔虎左旗| 垣曲县| 湘潭市| 靖远县|