Large File Uploads (> 4GB) with nginx and php-fpm
<p>I am trying to upload large files with nginx and php-fpm and my own PHP script.
For files larger than 4 GB the PHP upload fails. I get a HTTP 200 response with my error message from PHP.
print_r($_FILES) shows me:</p>

<pre><code>    [file] =&gt; Array
    (
        [name] =&gt; foo.dat
        [type] =&gt; 
        [tmp_name] =&gt; 
        [error] =&gt; 3
        [size] =&gt; 0
    )
</code></pre>

<p>According to <a href="http://php.net/manual/en/features.file-upload.errors.php" rel="nofollow">http://php.net/manual/en/features.file-upload.errors.php</a> error 3 means:</p>

<blockquote>
  <p>UPLOAD_ERR_PARTIAL
  Value: 3;
  The uploaded file was only partially uploaded.</p>
</blockquote>

<p>All the data gets sent to nginx and yet php says "size=0".
I tried the upload in an HTML form and as XMLHttpRequest with Google Chrome and Firefox, as well as with a little upload program in Java. So an error on the client side or the connection is unlikely.</p>

<p>According to Chrome Network Inspector all data gets sent correctly, the content length in the request header is correct. After the data is sent I get the server response within 5 seconds, so a timeout is unlikely.</p>

<p>My nginx configuration:</p>

<pre><code>client_max_body_size 8000m;
client_body_buffer_size 512k;

fastcgi_buffers 512 32k;
fastcgi_busy_buffers_size 128k;
fastcgi_buffer_size 128k;
fastcgi_temp_file_write_size 256k;
fastcgi_max_temp_file_size 0;
fastcgi_intercept_errors on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 18000;
fastcgi_read_timeout 1800;
</code></pre>

<p>And the php.ini for the php-fpm instance:</p>

<pre><code>upload_max_filesize = 8000M
post_max_size = 8000M
max_input_time = 1800
max_execution_time = 300
memory_limit = 512M
;upload_tmp_dir = // not specified, which means system default according to the php docs. That's /tmp on my machine
</code></pre>

<p>The nginx and php-fpm error log say nothing about this. I have restarted nginx and php-fpm multiple times already.</p>

<p>I am running nginx/1.6.0 with php 5.5.11 on Debian 6 64bit.</p>

<p>I will test this on a 2nd server now since I'm thinking the issue might be with Debian and outside of nginx/php-fpm.
Any ideas how to debug this further?</p>

<p><strong>UPDATE 1:</strong></p>

<p>There is enough disk space. To test for partition and/or permission problems I just created an upload folder under
a) the same mount point as the web root
b) and with the same user as php-fpm is running</p>

<p>so simply: upload_tmp_dir = /home/myuser/upload
and I restarted php-fpm</p>

<p>The problem is still the same, I get an HTTP 200 with php error=3 for the file upload. Smaller files can be uploaded and appear temporarily in the new temp folder.</p>

<p><strong>FIX</strong>
After updating to the latest php 5.6 version the error is gone. I am using the same php.ini file with that version, so it's probably a changed default setting or a fixed bug in php.</p>