Php ini upload_max_filesize not changing

I am trying to increase post_max_size to 1024MB, I am using ini_get('post_max_size') and phpinfo() to check the setting and post_max_size shows as 128M in both.

some phpinfo() on the server:

PHP Version 5.5.9-1ubuntu4.7
System  Linux Dalaran 3.13.0-49-generic #83-Ubuntu SMP Fri Apr 10 20:11:33 UTC 2015 x86_64
Build Date  Mar 16 2015 20:43:56
Server API  Apache 2.0 Handler
Configuration File (php.ini) Path   /etc/php5/apache2
Loaded Configuration File   /etc/php5/apache2/php.ini
Scan this dir for additional .ini files /etc/php5/apache2/conf.d
Apache Version  Apache/2.4.7 (Ubuntu)
user_dir    no value

/etc/php5/apache2/php.ini

669 ; Maximum size of POST data that PHP will accept.
670 ; Its value may be 0 to disable the limit. It is ignored if POST data reading
671 ; is disabled through enable_post_data_reading.
672 ; http://php.net/post-max-size
673 post_max_size = 1024M

I have restarted apache after each change. I also ran a grep on all directories in /etc/php5 and found no other reference to Post_max_size

Changing upload_max_filesize and memory_limit works fine.

No user_dir is set, so it should not be loading any .user.ini files.

Nothing useful in apache error log.

If you have any ideas for what I can check next please tell me.

I understand the most frustrating issue on WordPress is “the uploaded file exceeds the upload_max_filesize directive in php.ini.”

It happens when you try to:

  • Upload a huge image or video file on your WordPress.
  • Install a titanic size plugin or theme, especially when it has a lot of features.
  • Or any file that exceeds your upload max filesize.

Did you know?

The majority of the guides available on the internet don’t work to fix the issue of the upload max filesize since they try to increase the limit of upload_max_filesize only, but the element of post_max_size is also critical to solve it. Keep reading to learn more.

But don’t worry,  I’ll show you the screenshots of each step for effortless resolving the issue.

Excited?

Let’s first start with what causes the issues.

Reasons Behind the Error “the uploaded file exceeds the upload_max_filesize directive in php.ini.”

Well-reputed companies try to persuade consumers with different buying techniques, especially with the word “unlimited.”

Php ini upload_max_filesize not changing

You’ll find plenty of hosting companies claiming to be unlimited in terms of storage and bandwidth.

But the reality is the opposite.

They all have limitations usually depicted in the fair-usage policy or terms and conditions. These policies exist for a reason — preserving the hosting’s resources.

They know 90% of the websites will not get more than 1000 visits a month, imposing no threats to their valuable resources. To save from the rest, they put restrictions on the server, for example, not allowing to upload 20MB or bigger file size. This restriction saves a lot of valuable resources.

Php ini upload_max_filesize not changing

Let’s take an example of Namecheap, which doesn’t allow you to upload more than 300,000 files, aka inodes, in its shared hosting plan, and the maximum upload size limit is just 50MB.

Php ini upload_max_filesize not changing

The same is the case with the upload max file size limit.

You might be wondering where the default setting is saved? Generally, it exists in the php.ini file.

The default php.ini looks like this:

Some people blame WordPress for the lower limit of max upload size, but it’s not true. WordPress has nothing to do with php.ini. It doesn’t come with the default WordPress installation.

Here are all the files after unzipping the WordPress file downloaded from the official WordPress website — no php.ini is available.

Php ini upload_max_filesize not changing

Rather it’s the limitation imposed by your hosting in the php.ini or similar alternatives that control the server resources.

Let’s dive into solving this problem.

6 Ways to Fix the uploaded file exceeds the upload_max_filesize

1. Your Hosting Support

It’s obvious, I know. 😁 But some people hesitate to contact their hosting providers; otherwise, it’s the fastest way to fix the issue.

Keep in mind that the support of all hosting companies is not the same. For example, the industry-leading hosting provider Bluehost is one of the worst hosting companies on the planet.

Php ini upload_max_filesize not changing

Scroll down a little; you’ll come to know about shocking stories about Bluehost.

Php ini upload_max_filesize not changing

It doesn’t mean we’re against Bluehost personally, but the same is the case with Hostgator.

Php ini upload_max_filesize not changing

The takeaway is to get a great hosting company that has exceptional support.

At One Smart Sheep, we understand that clients are the most valuable assets. Their issues are solved on an immediate basis.

What does One Smart Sheep do?

We build world-class websites from the ground up and provide ultra-fast hosting, maintenance, and dedicated managers for outstanding support over phone, email, and live chat, including everything in $49/month.

2. Use MultiPHP INI Editor in cPanel

cPanel makes life easier for people to manage their websites at their fingertips. It provides dozens of tools from installing an SSL certificate to backup.

It has a separate tool to increase the max upload size limit known as MultiPHP INI Editor.

Php ini upload_max_filesize not changing

When you click on it, you can select any website from the drop menu to increase the limit.

Php ini upload_max_filesize not changing

You’ll see many PHP directives. In order to increase the upload_max_filesize, please increase the limits of two directives:

  • post_max_size: 5000M
  • upload_max_filesize: 5000M

Enter any value. Here M stands for MegaBytes. If you want to have a limit of 50GB, you need to type 50000M.

You can see the limit in the library.

Php ini upload_max_filesize not changing

Note: Most people make mistakes to increase only the value of upload_max_filesize, but you have to increase for post_max_filesize as well in order to work.

Did you know? When you make changes in the MULTI PHP Editor,  cPanel creates a file php.ini in your root directory automatically. It runs as:

; cPanel-generated php ini directives, do not edit

; Manual editing of this file may result in unexpected behavior.

; To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)

; For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)

display_errors = Off

max_execution_time = 90

max_input_time = -1

max_input_vars = 1000

memory_limit = 128M

post_max_size = 50000M

session.gc_maxlifetime = 1440

session.save_path = “/var/cpanel/php/sessions/ea-php73”

upload_max_filesize = 50000M

zlib.output_compression = Off

3. Increase upload_max_filesize value by editing .htaccess 

Do you know? You can increase the upload_max_fileize with the help of .htaccess easily.

First, you need to find where .htaccess is located basically in the root directory of your website.

If you’re using cPanel, go to File Manager. If you own a single website, navigate to public_html, but you own multiple domains, you’ll see different folders on the left side of File Manager.

Php ini upload_max_filesize not changing

Right-click on the .htaccess file and hit Edit.

Php ini upload_max_filesize not changing

You’ll get a warning to make a backup before making any changes, but don’t worry, again hit Edit.

Php ini upload_max_filesize not changing

Now paste the below code after the line “# Any changes to the directives between these markers will be overwritten.”

php_value upload_max_filesize 5000M

php_value post_max_size 5000M

php_value memory_limit 256M

php_value max_execution_time 300

php_value max_input_time 300

Php ini upload_max_filesize not changing

And hit Save Changes.

Php ini upload_max_filesize not changing

Done!

Note: In the new installation of WordPress, you might not see .htaccess. In order to create it, either you have to make changes to your permalink or manually upload the default .htaccess file.

Php ini upload_max_filesize not changing

In order to manually upload it, firstly download the default .htaccess file. The default .htaccess runs as:

# BEGIN WordPress

RewriteEngine On

RewriteRule .* – [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

RewriteBase /

RewriteRule ^index.php$ – [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]

# END WordPress

And upload in the root directory of your website.

Php ini upload_max_filesize not changing

And edit it the way I explained above.

4. Editing wp-config.php File

In some cases, no method might work for you.

It’s pretty simple.

Again go back to cPanel > File Manager > the root directory of your website.

Find wp-config.php.

Php ini upload_max_filesize not changing

Right-click to edit.

Php ini upload_max_filesize not changing

Now paste the below code as shown in the screenshot below.

@ini_set( ‘upload_max_filesize’ , ‘5000M’ );

@ini_set( ‘post_max_size’, ‘5000M’);

@ini_set( ‘memory_limit’, ‘256M’ );

@ini_set( ‘max_execution_time’, ‘300’ );

@ini_set( ‘max_input_time’, ‘300’ );

Php ini upload_max_filesize not changing

Don’t forget to save changes.

Php ini upload_max_filesize not changing

5. Create or Edit php.ini via cPanel

Some hosting might not have the option of Multi PHP INI Editor; you need to edit php.ini. If this php.ini doesn’t exist, you can create your own.

Download the default version of php.ini as per your PHP version.

Download default php.ini 5.4

Download default php.ini 5.5

Download default php.ini 5.6

Download default php.ini 7.0

Download default php.ini 7.1

Download default php.ini 7.2

Download default php.ini 7.3

You might be thinking about how to check the PHP version? Navigate to the Software in cPanel and click MultiPHP Manager.

Php ini upload_max_filesize not changing

Here you can see the current version of your website.

Php ini upload_max_filesize not changing

In my case, I’m running PHP version 7.3. So I’ll download the default file of php.ini for 7.3.

The issue is that it has a filename that needs to be changed from php-72-ini.txt to php.ini.

Php ini upload_max_filesize not changing

It doesn’t work until you check File name extensions from the View section in Windows 10.

Php ini upload_max_filesize not changing

In Mac, you can find it in Finder Preferences.

Php ini upload_max_filesize not changing

Now go back to cPanel home and find File Manager.

Php ini upload_max_filesize not changing

Navigate to your website name shown as a folder name on the left side and click upload.

Php ini upload_max_filesize not changing

Before we upload the php.ini, let’s edit it for upload_max_filesize and post_max_filesize.

Php ini upload_max_filesize not changing

The default is 2M, but you can change it to any value you desire. I choose 50000M, exactly 50GB. It’s not done yet. Find another value post_max_size.

Php ini upload_max_filesize not changing

Now it’s time to save changes.

Php ini upload_max_filesize not changing

Now upload the php.ini file into the root directory of your WordPress website.

Php ini upload_max_filesize not changing

And here is the final version of php.ini.

Php ini upload_max_filesize not changing

6. Use FTP to Edit wp-config.php and .htaccess

The use of cPanel is declining thanks to cloud computing that enables you to manage your website at insanely cheap rates.

Php ini upload_max_filesize not changing

DigitalOcean, Vultr, Linode, AWS, Microsoft Azure, and Google Cloud Platform are among the best cloud hosting on the planet.

If you make a site on it, you’re generally given access to FTP. In order to access FTP, download Filezilla, the most famous client to communicate with your site over FTP.

Php ini upload_max_filesize not changing

I always use Google Sheet to store my confidential information.

Php ini upload_max_filesize not changing

So, I’ll use the above information to connect with my FTP server. I put the VPS server IP into the host box, username as root, password, and left port as empty.

And the important thing, I put /var/www/html into the remote site box as WordPress is installed in this folder by default.

Php ini upload_max_filesize not changing

First of all, I’ll edit the .htaccess. It’s simple. Right-click .htaccess and click edit.

Php ini upload_max_filesize not changing

It asks for a default code editor. I use Microsoft Visual Studio Code. The default location is

“C:UsersYOURUSERNAMEAppDataLocalProgramsMicrosoft VS CodeCode.exe”

Don’t forget to replace your Windows username.

Now copy the below code and paste before #END WordPress.

Php ini upload_max_filesize not changing

php_value upload_max_filesize 5000M

php_value post_max_size 5000M

php_value memory_limit 256M

php_value max_execution_time 300

php_value max_input_time 300

And now press Ctrl+S in order to save it.

Now close the Visual Code window. Instantly, FileZilla will ask for permission to delete the local file and save it to your server.

Php ini upload_max_filesize not changing

Enable “Finish editing and delete local file” and click Yes.

If it doesn’t work, use the wp-config edit.

Php ini upload_max_filesize not changing

And paste the below code before Happy Blogging.

Php ini upload_max_filesize not changing

Save changes.

Php ini upload_max_filesize not changing

Close the Window. Filezilla will ask again for permission.

Php ini upload_max_filesize not changing

Check “Finish editing and delete local file” and click Yes.

Things To Do After Making Changes…

  • If you’re using VPS hosting.

If you’re using a VPS hosting like DigitalOcean, Vultr, or Linode, don’t forget to restart your server.

It’s straightforward.

Sign in to your platform and run Console.

Php ini upload_max_filesize not changing

Enter your username and password and type reboot, and hit enter.

Php ini upload_max_filesize not changing

  • If you’re using cPanel hosting.

cPanel hosting doesn’t allow you to restart your server. The only option is to clear your cache.

Sign in to your WordPress and purge all cache.

Php ini upload_max_filesize not changing

  • If you’re using Cloudflare

If you use Cloudflare, you should clear your cache. It’s effortless to perform. Sign in to your Cloudflare account, navigate to Caching, click Configuration, and hit Purge Everything.

Php ini upload_max_filesize not changing

Final Thoughts

I’m 100% sure your problem will be solved upon trying all the ways we have mentioned. As I depicted in the introduction, the error isn’t fixed until you increase two values: upload_max_filesize and post_max_size.

In a nutshell, if you’re a cPanel user, the best way is to use a Multi PHP Editor. If you use a VPS hosting like DigitalOcean, then .htaccess and wp-config.php are the best ways to solve it.

Let us know which method worked for you?

How do I change upload_max_filesize directive in PHP ini?

Log into your hosting account..
Open cPanel..
Go to Select PHP Version > PHP Options/Options. Or, in some situations, you might need to look for a tool called MultiPHP INI Editor..
Change the value for upload_max_filesize according to your needs..

How do you fix the setting for Post_max_size is smaller than upload_max_filesize?

Navigate to your php. Locate the upload_max_filesize and increase it by changing its number. You can also boost a few other limitations, as shown below: upload_max_filesize = 256M post_max_size = 256M memory_limit = 512M max_execution_time = 180. Save the file, and that's it. The error should no longer occur.

Where is upload_max_filesize in PHP ini?

The upload_max_filesize directive itself is located in the php. ini file, which is the default server configuration file for applications that require PHP.

How do I change the maximum file upload size in PHP ini Ubuntu?

Ubuntu Linux Instructions.
Type "sudo nano /etc/php5/apache2/php.ini".
Press Ctrl and W and type "post_max_size".
Change the value to the number of Mb you want your site to accept as uploads..
Press Ctrl and W and type "upload_max_filesize".
Change the value to the number of Mb you want your site to accept as uploads..