0

I would like to upload relatively big file via a php api (around 4M). In the beginning of my php5 script I set the following options :

ini_set("upload_max_filesize","100M");
ini_set("post_max_size","108M");
ini_set("max_execution_time","3000");
ini_set("memory_limit","500M");
ini_set("max_input_time","3000");
ini_set("output_buffering","0");

plus I add the following params to nginx config file:

client_max_body_size 500M; 
fastcgi_read_timeout 600s;
keepalive_timeout 3000; 
client_header_timeout 1000m;
client_body_timeout 1000m;
client_header_buffer_size 2k;

And this has slightly improved the situation as I had this error:

POST Content-Length of 78014353 bytes exceeds the limit of 8388608 bytes in Unknown on line 0

And now, my error occurs a bit later on the process (when I try to move an un-uploaded file with the function moveTo of Slim framework)

error exception 'RuntimeException' with message '  is not a valid uploaded file'

Do you have some suggestions on what I could try to fix it?

Edit:

I forget to precise that the upload works well as long as the archive file to upload is small (<2M)

Edit 2:

I try to modify the file /etc/php5/fpm/php.ini instead of modifying the parameters directly on my php script, but I get the following issue.

After restarting php5-fpm and nginx, my new paramaters are not taken into account:

>>php5-fpm -i | grep "post_max"
post_max_size => 8M => 8M

Nevertheless it seems that I modify the good configuration file:

>>php5-fpm -i | grep "php.ini"
Configuration File (php.ini) Path => /etc/php5/fpm
Loaded Configuration File => /etc/php5/fpm/php.ini

I try to check if some other ini files overwriting my change were loaded:

root@test2:~# php5-fpm -i | grep ".ini"
Configuration File (php.ini) Path => /etc/php5/fpm
Loaded Configuration File => /etc/php5/fpm/php.ini
Scan this dir for additional .ini files => /etc/php5/fpm/conf.d
Additional .ini files parsed => /etc/php5/fpm/conf.d/05-opcache.ini,
/etc/php5/fpm/conf.d/10-mysqlnd.ini,
/etc/php5/fpm/conf.d/10-pdo.ini,
/etc/php5/fpm/conf.d/20-curl.ini,
/etc/php5/fpm/conf.d/20-gd.ini,
/etc/php5/fpm/conf.d/20-json.ini,
/etc/php5/fpm/conf.d/20-mcrypt.ini,
/etc/php5/fpm/conf.d/20-mosquitto.ini,
/etc/php5/fpm/conf.d/20-mysql.ini,
/etc/php5/fpm/conf.d/20-mysqli.ini,
/etc/php5/fpm/conf.d/20-pdo_mysql.ini,
/etc/php5/fpm/conf.d/20-readline.ini
user_ini.cache_ttl => 300 => 300
user_ini.filename => .user.ini => .user.ini
Supported handlers => cdb cdb_make db4 inifile flatfile qdbm 
com_init_db => 0
Classes => AppendIterator, ArrayIterator, ArrayObject, BadFunctionCallException, BadMethodCallException, CachingIterator, CallbackFilterIterator, DirectoryIterator, DomainException, EmptyIterator, FilesystemIterator, FilterIterator, GlobIterator, InfiniteIterator, InvalidArgumentException, IteratorIterator, LengthException, LimitIterator, LogicException, MultipleIterator, NoRewindIterator, OutOfBoundsException, OutOfRangeException, OverflowException, ParentIterator, RangeException, RecursiveArrayIterator, RecursiveCachingIterator, RecursiveCallbackFilterIterator, RecursiveDirectoryIterator, RecursiveFilterIterator, RecursiveIteratorIterator, RecursiveRegexIterator, RecursiveTreeIterator, RegexIterator, RuntimeException, SplDoublyLinkedList, SplFileInfo, SplFileObject, SplFixedArray, SplHeap, SplMinHeap, SplMaxHeap, SplObjectStorage, SplPriorityQueue, SplQueue, SplStack, SplTempFileObject, UnderflowException, UnexpectedValueException

But I did not find my parameters being explicitly redefined in any of this files...

Sophie Jacquin
  • 194
  • 2
  • 10

1 Answers1

1

I finally found the solution on a relative stack overflow question : Changes to upload_max_filesize in Ubunutu php.ini will not take effect

So, what has work for me was to follow the advices of Jekis:

Folow these steps to resolve the issue:

  1. Eval phpinfo(); Search for 'Scan this dir for additional .ini files' text in phpinfo() output It will be something like this /etc/php5/apache2/conf.d
  2. Create your user.ini file inside the dir. (/etc/php5/apache2/conf.d/user.ini)
  3. Use this ini file for custom settings.
  4. Restart the server

This is because:

The newest php version installed on server does not allow global settings (such as execution time, max upload filesize, max post file size, etc.) to be changed.

Sophie Jacquin
  • 194
  • 2
  • 10