Search code examples
phpwordpressnginxphp-7

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


Before you mark this as duplicate, hear me out. I've tried all the suggestions I can find online. None works. I've restarted countless times. Detailed list of what I've tried below.

Here's my setup:

  • Nginx 1.10
  • PHP 7.0
  • WordPress 4.7
  • I'm on a VPS. I have access and control over EVERY single file!

Here's what I want to do:

  • Increase the upload file size for my WordPress.

Why?

  • Anytime I upload a file size bigger than 2 megabytes, I get this error: The uploaded file exceeds the upload_max_filesize directive in php.ini. That's all it tells me.

Here's what I have done:

  1. a. So out of common sense, I go into /etc/php/7.0/cli/php.ini because php.ini -i tells me the loaded configuration is from that file. In the php.ini file, I change the upload_max_filesize = 2M to upload_max_filesize = 10M

    b. I go ahead to restart, both Nginx (sudo service nginx restart), and PHP (sudo service php7.0-fpm restart)

Above Doesn't work as 2 other approaches below: I still get:

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

  1. I create my own user.ini under /etc/php/7.0/cli/conf.d/ folder with contents, upload_max_filesize = 10M

I go ahead to do 1. b. Still same error

  1. They say something is called error_reporting. I go ahead to locate the error reporting in my php.ini file. I change from the first line below to the second: ;error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT error_reporting = E_ALL

I do 1. b., Still doesn't work.

So what the #&)#(* is wrong with my setup and what again do I have to change somewhere else?

Is it even changeable? I've read and tried almost every single suggestion online, and it never works.

It has never been an issue for me, the 2 max upload, but I'm importing a wordpress xml file, which is just 3 Mb, and I've spent a couple of hours already trying to get this thing to work.

By default, can't the upload size be a bit higher. 2 Megabyte is even ridiculous for a site in recent years. At least 5 is much better.

Any help is appreciated!


Solution

  • You're looking at the php.ini file for the CLI, you need to look at the PHP ini file for the web server you're running. Within the WP directory, create a temporary php file, and have it contain <?php phpinfo(); navigate to that file in the browser and find the php.ini file you actually need to change, then make the change as required.

    NOTE: Remove this file once you're done with your checks, having this information visible to the public is a security risk