PHP 中限制下载速度
我已经尝试过在谷歌搜索中找到的基本方法,甚至尝试自己编写一个,但是我一直遇到问题。好像是在服务器端下载内容什么的,然后推送给用户,就已经下载好了。它将打开下载页面,大约需要 10 秒的时间来下载,然后将文件完整地提供给用户,这使得它看起来像是没有下载。
我想知道是否有任何已编写的类来限制下载速度,或者我如何解决这个问题。
我目前有这个;
header("Content-type: application/force-download");
header("Content-Transfer-Encoding: Binary");
header("Content-length: ".filesize("uploads/$filename"));
header("Content-disposition: attachment; filename=\"$origname");
readfile("uploads/$filename");
谢谢!
I have tried the basic ones found in a Google search and even tried to write one myself, however i keep getting a problem with it. It seems to download the content server-side or something and then push it to the user, which will already have been downloaded. It will open the download page and take around 10 seconds to download and then give the file to the user in full, which makes it look like its not downloading.
I was wondering if there are any classes that have been written to throttle download speeds, or how i can fix this problem.
I have this currently;
header("Content-type: application/force-download");
header("Content-Transfer-Encoding: Binary");
header("Content-length: ".filesize("uploads/$filename"));
header("Content-disposition: attachment; filename=\"$origname");
readfile("uploads/$filename");
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这将向用户发送一个下载速度受到限制的文件。它的工作原理基本上是这样的:
This will send a file with throttled download speed to the user. It works basically like this:
您可能会发现我的 alpha 阶段 感兴趣的带宽项目。可能还需要做更多的工作,但已经有很多有趣的东西了。我认为它还没有 F/OSS 许可证;如果你想让我给它一个,请告诉我!
You might find my alpha-stage Bandwidth project of interest. Probably needs a bit more work, but there's plenty of interesting stuff already. I don't think it has a F/OSS license yet; ping me if you want me to give it one!
现在有:
带宽节流/带宽节流
Now there is:
bandwidth-throttle/bandwidth-throttle