Search code examples
phpnginxfile-uploadlarge-files

Unable to upload files over 500MB while upload_max_filesize is set to 1G


I realise there are a ton of questions on this already but i've followed all of them and can't find any information on how to further debug this not working.

I can upload a file of 490 MB absolutely fine. I cannot upload a file of 562.8 MB.

I'm running php 7.0.11 with fpm, nginx 1.11.3, ubuntu 16 and using Laravel 5.1

My php ini settings are:

upload_max_filesize 1GB

post_max_size 1GB

memory_limit 1GB (this shouldn't actually be needed but i've tried it anyway)

My nginx settings:

client_max_body_size 1G

I haven't found any reference to any other variables that need to be changed or that may interfere.

When I upload $_FILES looks like:

["file"]=>
  array(5) {
    ["name"]=> string(36) "CSBgGvDIAaZtbC4lmliLevHf0bAnWiKM.rar"
    ["type"]=> string(0) ""
    ["tmp_name"]=> string(0) ""
    ["error"]=> int(1)
    ["size"]=> int(0)
  }

There is nothing in my nginx or php error logs.

$_SERVER['content_length'] is 652844444 which is the correct length of the file.

The 'error' is listed as 1. I don't know if this is 1 as in true, or 1 as in the relevant error message. The php docs list the error message for 1 in the docs as:

The uploaded file exceeds the upload_max_filesize directive in php.ini.

But both of:

echo phpinfo();
echo ini_get('upload_max_filesize');

Show 1GB so the file shouldn't exceed it, because it's 562.8 MB.

With no further error messages and having followed every instruction and guide I can find on Google i'm at a complete loss as to what it could be.

I am also using Cloudflare but it is turned off for this sub domain and the limits on Cloudflare are 100MB not 500MB so I don't think it's anything to do with that.

Is there any way to further debug this? I'm at a complete loss at this point.


Solution

  • So I solved this. Really really annoyingly. The problem was that I typed 1GB instead of 1G in php.ini. No error messages were given and it wasn't clear at all that it wasn't using 1 Gigabyte. But php.ini won't recognise things like 1KB, 1MB or 1GB you have to use without the B.

    Lesson learned, alot of time wasted.