Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

php

upload

ini

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

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".

So only the first 7 images get uploaded (each is in three sizes, 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.

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

like image 268
Jon M Avatar asked Mar 22 '10 12:03

Jon M


2 Answers

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

like image 91
Pekka Avatar answered Oct 19 '22 10:10

Pekka


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

php_value max_file_uploads 40

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

php_value upload_max_filesize 25M
php_value post_max_size 25M
php_value max_file_uploads 1000

;)

damian rossi

like image 29
damian Avatar answered Oct 19 '22 11:10

damian