简体   繁体   English

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

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

Like many variables in PHP using ini_set() on a page doesn't actually work. 像PHP中使用ini_set()的许多变量一样,实际上并不起作用。

I've recently upgraded my PHP version and found that my multiple image uploader is now capped. 我最近升级了我的PHP版本,发现我的多图像上传器现在已经上限了。 After 3 hours of frustration, I've found that my new PHP install has the new "max_file_uploads" parameter set to "20". 经过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. 我现在可以将我的php.ini值“max_file_uploads”更改为300,但我宁愿不做那边广泛。

Is there any way to set that value just for a single file (upload.php)? 有没有办法为单个文件(upload.php)设置该值? Could a .htaccess file be used for this? 可以使用.htaccess文件吗?

Correction: max_file_uploads can NOT be changed outside php.ini. 更正:不能在php.ini外部更改max_file_uploads。 See PHP "Bug" #50684 请参阅PHP“Bug”#50684

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 达米安罗西

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM