PHP:为一个文件设置 max_file_uploads 而不是 php.ini

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2492234/
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-08-25 06:41:56  来源:igfitidea点击:

PHP: Set max_file_uploads for one file rather than php.ini

phpuploadini

提问by Jon M

Like many variables in PHP using ini_set() on a page doesn't actually work.

就像在页面上使用 ini_set() 的 PHP 中的许多变量实际上不起作用。

I've recently upgraded my PHP version and found that my multiple image uploader is now capped. After 3 hours of frustration, I've found that my new PHP install has the new "max_file_uploads" parameter set to "20".

我最近升级了我的 PHP 版本,发现我的多图像上传器现在被限制了。经过 3 个小时的挫折,我发现我的新 PHP 安装将新的“max_file_uploads”参数设置为“20”。

So only the first 7 images get uploaded (each is in three sizes, 7*3=21).

所以只有前 7 张图片被上传(每张有三种尺寸,7*3=21)。

I can now change my php.ini value of "max_file_uploads" to 300, but I'd rather not do that side wide.

我现在可以将“max_file_uploads”的 php.ini 值更改为 300,但我宁愿不这样做。

Is there any way to set that value just for a single file (upload.php)? Could a .htaccess file be used for this?

有没有办法只为单个文件(upload.php)设置该值?可以为此使用 .htaccess 文件吗?

回答by Pekka

Correction:max_file_uploads can NOT be changed outside php.ini. See PHP "Bug" #50684

更正:不能在 php.ini 之外更改 max_file_uploads。参见PHP“错误”#50684

回答by damian

Yes it can be changed. Use the .htaccess file and add this:

是的,它可以改变。使用 .htaccess 文件并添加以下内容:

php_value max_file_uploads 40

example, i use this in my .htaccess in the folder:

例如,我在文件夹中的 .htaccess 中使用它:

php_value upload_max_filesize 25M
php_value post_max_size 25M
php_value max_file_uploads 1000

;)

;)

damian rossi

达米安罗西