php实现下载限制速度示例分享_php实例_脚本之家

// flush contentflush();

复制代码 代码如下:// local file that
should be send to the client$local_file = ‘test-file.zip’;

// close file streamfclose;

if(file_exists && is_file {

www.6766.com,// send the current file part to the browserprint fread($file,
round($download_rate * 1024));

// open file stream$file = fopen;

}

while {

// set the download rate limit $download_rate = 20.5;

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

// flush the content to the browserflush();

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

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

// sleep one secondsleep;}

相关文章

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图