php - 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:

  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.




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.




Are you using a cloud/hosted server? Many hosted servers have hard limits on max file uploads that they don't let you override even with an ini file. If you are using a hosted server, you may need to contact your hosting provider to override the limit for you.




if you are using wp site plugin consider change both Constants in wp-config.php update not worked .so many developer suggest in stackOverflow) after do like this worked .ubuntu 20

sudo nano /etc/php/7.4/apache2/php.ini


post_max_size = 1G

upload_max_filesize = 1G

People are also looking for solutions to the problem: string - How can I return a percentage in PHP?


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.