使用PHP来限制下载速度 [英] Using PHP to limit download speed
问题描述
:confused :: confused:
我一直在寻找一个可以提供下载文件的php脚本,并限制文件传输到的速度用户。我希望注册会员的下载速度更快,而且客人的速度会更慢。
我唯一能想到的是使用header()函数强制下载所请求的内容文件类型并将文件流式传输到用户的浏览器。然后在循环中使用sleep()或usleep()直到下载完成。
任何人都有任何建议或想法吗?
~Chipgraphics
这是我在php.net上找到的一个片段。
展开 | 选择 | Wrap | 行号
随着协议的不断变化和编程yada yada。我阅读了你的建议并将一些概念合并到一个包裹中。它在第一次尝试时起作用了! :D所以,谢谢你指点我正确的方向!我会在下面列出我的源代码。
这里有一个使用PHP控制下载带宽的功能:
我从PHP的在线文档中借用的所有原始代码 HERE 。
展开 | 选择 | Wrap | 行号
嘿,恭喜你得到你想要的结果。
谢谢用于发布代码供人们学习,这就是这个论坛的全部内容。
~KUB
:confused::confused:
I have been on the quest to find a php script that can serve files for downloads and limit the speed at which the file is transfered to the user. I want a faster download speed for registered members and a slower speed for guests.
The only other thing I can think of is using the header() function to force a download for the requested file type and stream the file to the user''s browser. Then using sleep() or usleep() on a loop until the download completes.
Anyone have any suggestions or ideas?
~Chipgraphics解决方案Here is a snippet i found on php.net.
Expand|Select|Wrap|Line Numbers
With the constant change of protocols and programming yada yada. I read over what you had suggested and combined a couple of the concepts into one package deal. And it worked on the first try ! :D So, thank you for pointing me in the right direction ! I''ll list my source code below.
Here''s a function to use PHP to control download bandwith speed:
All original code I borrowed from PHP''s online documentation found HERE.
Expand|Select|Wrap|Line Numbers
Hey, congrats on getting the results you were looking for.
Thanks for posting the code for people to learn from, that''s what this forum is all about.
~KUB
这篇关于使用PHP来限制下载速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文登录 关闭
扫码关注1秒登录发送“验证码”获取 | 15天全站免登陆