如何在 php 或 apache 中限制文件上传速度?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2306112/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 18:48:52  来源:igfitidea点击:

How to limit file upload speed in php or apache?

phpapachezend-frameworkfile-upload

提问by Marcin

I'm doing some form in Zend Framework for file upload on "Apache friends - xampp" server 1.7.1 on Ubuntu 9.10.

我正在 Zend Framework 中执行某种形式,以便在 Ubuntu 9.10 上的“Apache 朋友 - xampp”服务器 1.7.1 上上传文件。

My problem is that I what to add progress bar for this upload and since xampp server is on my localhost, file uploads are very fast. As a result, I have no time to check or observer if progress bar works as it should.

我的问题是我要为此上传添加进度条,并且由于 xampp 服务器位于我的本地主机上,因此文件上传速度非常快。结果,我没有时间检查或观察进度条是否正常工作。

Is there an easy way (some option in PHP, Zend Framework or Apache) to reduce the file upload speed to e.g. 20kB/s.

是否有一种简单的方法(PHP、Zend Framework 或 Apache 中的某些选项)可以将文件上传速度降低到例如 20kB/s。

I tried to use mod_bwfor Apache but it seems that it limits only downloads from the server, not the uploads to the server. I also tried to upload large files, like 400MB, but it is not good, since my web browser nearly crashes.

我尝试将mod_bw用于 Apache,但它似乎只限制从服务器下载,而不是上传到服务器。我还尝试上传大文件,例如 400MB,但效果不佳,因为我的网络浏览器几乎崩溃。

采纳答案by Pascal MARTIN

You should take a look at the answers to these questions :

你应该看看这些问题的答案:

Those will not be only for PHP/Apache, but might help anyway...

这些不仅适用于 PHP/Apache,而且可能会有所帮助......

回答by Leo

You can use the Apache-Module mod_bw: http://bwmod.sourceforge.net/

您可以使用 Apache 模块 mod_bw:http://bwmod.sourceforge.net/

Another alternative would be mod_cband: http://codee.pl/cband.html

另一种选择是 mod_cband:http://codee.pl/cband.html

Although they usually refer to download-speed, the limitations should have effect for uploads as well.

尽管它们通常指的是下载速度,但这些限制也应该对上传产生影响。

Edit: just tested bwmod and limitation is only for download...

编辑:刚刚测试了 bwmod 和限制仅用于下载...