title: upload large files with php nginx
body: <p>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 : </p>
  
  <pre><code>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");
  </code></pre>
  
  <p>plus I add the following params to nginx config file:</p>
  
  <pre><code>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;
  </code></pre>
  
  <p>And this has slightly improved the situation as I had this error:</p>
  
  <pre><code>POST Content-Length of 78014353 bytes exceeds the limit of 8388608 bytes in Unknown on line 0
  </code></pre>
  
  <p>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)</p>
  
  <pre><code>error exception 'RuntimeException' with message '  is not a valid uploaded file'
  </code></pre>
  
  <p>Do you have some suggestions on what I could try to fix it?</p>
  
  <p>Edit:</p>
  
  <p>I forget to precise that the upload works well as long as the archive file to upload is small (&lt;2M)</p>
  
  <p>Edit 2:</p>
  
  <p>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.</p>
  
  <p>After restarting php5-fpm and nginx, my new paramaters are not taken into account:</p>
  
  <pre><code>&gt;&gt;php5-fpm -i | grep "post_max"
  post_max_size =&gt; 8M =&gt; 8M
  </code></pre>
  
  <p>Nevertheless it seems that I modify the good configuration file:</p>
  
  <pre><code>&gt;&gt;php5-fpm -i | grep "php.ini"
  Configuration File (php.ini) Path =&gt; /etc/php5/fpm
  Loaded Configuration File =&gt; /etc/php5/fpm/php.ini
  </code></pre>
  
  <p>I try to check if some other ini files overwriting my change were loaded:</p>
  
  <pre><code>root@test2:~# php5-fpm -i | grep ".ini"
  Configuration File (php.ini) Path =&gt; /etc/php5/fpm
  Loaded Configuration File =&gt; /etc/php5/fpm/php.ini
  Scan this dir for additional .ini files =&gt; /etc/php5/fpm/conf.d
  Additional .ini files parsed =&gt; /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 =&gt; 300 =&gt; 300
  user_ini.filename =&gt; .user.ini =&gt; .user.ini
  Supported handlers =&gt; cdb cdb_make db4 inifile flatfile qdbm 
  com_init_db =&gt; 0
  Classes =&gt; 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
  </code></pre>
  
  <p>But I did not find my parameters being explicitly redefined in any of this files...</p>