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

Solution:1

Are you trying to upload the new media via WordPress? Please try via FTP.

Option 3 – Try uploading files via FTP.


You’ve already tried Options 1 and 2.

Option 1 – Find php.ini and change:

; Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
upload_max_filesize = 2M

Option 2 – Try asking your hosting provider to increase the php memory limit for you.

Solution:2

In order to fix this error, you need to increase the file size upload limit. That is, you need to increase the value of the upload_max_filesize directive in your php.ini file.

There are several different ways you can do this – the exact method that you choose will depend on your preference and your host’s configuration.

1. Talk to your host’s support

While we’ll cover some methods that you can try by yourself, the simplest solution is usually to just reach out to your host’s support and ask them to increase the limit for you.

This is a common request, your host’s support should know exactly what you want, and it should only take a couple of minutes of your time. That’s what your host’s support is there for!

If you host at Kinsta and need to increase your limit beyond the default 128 MB limit, you can reach out to support on Intercom from anywhere in your Kinsta dashboard:

 

2. Edit php.ini via cPanel

If your host uses cPanel, you should be able to edit your php.ini file and upload_max_filesize directive via the cPanel dashboard.

First, look for the MultiPHP INI Editor:

 

The MultiPHP INI Editor in cPanel

Then choose your WordPress site from the drop-down. After that, you’ll be able to edit the upload_max_filesize directive for that site:

 

 

.

Changing the upload_max_filesize directive in cPanel

Increase the value based on your needs.

3. Create or edit php.ini via FTP

As you learned above, the php.ini file controls how your server works for PHP applications.

Unfortunately, based on your host’s restrictions, you may or may not be able to use php.ini files. For that reason, a more reliable approach can sometimes be to use .htaccess (which we’ll cover in the next section).

However, you can give this a try first to see if you are allowed to use php.ini at your host.

To get started, connect to your server via FTP and go to your site’s root folder.

If you already see a php.ini file in the root folder, you can edit that file. Otherwise, create a new file and name it php.ini:

 

How to create a new php.ini file

Then add or modify the code snippet below:

Struggling with downtime and WordPress problems? Kinsta is the hosting solution designed to save you time! Check out our features
  • If you created a new file, paste in the code snippet and modify the numbers to suit your needs.
  • If you’re editing an existing file, find the same directives in the existing file and modify the numbers to suit your needs.

upload_max_filesize = 12M
post_max_size = 13M
memory_limit = 15M

 

Adding the code to the php.ini file

Some hosts might further require you to add the suPHP directive in your site’s .htaccess file in order for the changes above to actually work.

To do this, you can also edit your .htaccess file via PHP and add the following code near the top of the file:

<IfModule mod_suphp.c>
suPHP_ConfigPath /home/yourusername/public_html
</IfModule>

Make sure to replace yourusername with the actual file path of your site.

4. Increase upload_max_filesize value by editing .htaccess

If directly creating or editing the php.ini file via the methods above didn’t work, you can also try to modify the upload_max_filesize directive by editing your site’s .htaccess file.

To get started, connect to your site via FTP and edit the .htaccess file that’s located in your site’s root folder.

Then, add the following code snippet, making sure to adjust the values based on your needs:

php_value upload_max_filesize 12M
php_value post_max_size 13M
php_value memory_limit 15M

 

 

How to control php.ini file via .htaccess

If you get an internal server error message after adding this code snippet, your server is likely running PHP in CGI mode, which means you cannot use these commands in your .htaccess file. Remove the snippets you just added and your site should start functioning again.