When you first add a website to hosting, you might encounter the error The uploaded file exceeds the upload_max_filesize directive in php.ini when uploading a plugin or theme, because new hosting accounts usually have a default max upload of only 2MB.
If you experience this issue, you can try several methods discussed in this article.
How to Fix The uploaded file exceeds the upload_max_filesize directive in php.ini
As the name suggests, the error The uploaded file exceeds the upload_max_filesize directive in php.ini occurs because the upload limit in your PHP configuration is lower than the size of the file you are trying to upload.
To resolve this issue, you can try the following options (in this example, we are using cPanel hosting)
Option 1. Update the .htaccess File
You can perform this update via the file manager, or you can also use FTP. If you are using the file manager, for example from cPanel, make sure to show hidden files within it, because .htaccess is a hidden file that is not displayed by default.
Once you have found the .htaccess file, simply edit it and add the following lines below # END WordPress or above # BEGIN WordPress
php_value upload_max_filesize 128Mphp_value post_max_size 256MAfter making the changes, the result should look something like this
After updating .htaccess, you can check the upload_max_filesize in your WordPress by opening the page Media > Add new media file
Option 2: Update php.ini
If your hosting or server does not have a PHP Selector, the PHP configuration is usually stored in a file named php.ini
Usually, the Max Upload configuration is already inside the php.ini file and you only need to change the value. However, if it is not there, or if the file does not exist, you can create a new file and add the following lines
post_max_size = 18Mupload_max_filesize = 12MIf you are editing an existing file, the result will look like this
Now you can check the maximum file size you can upload via the page Media > Add new media file via the WordPress dashboard
Option 3: Update wp-config.php
In addition to the previous options, you can also perform an update via wp-config.php.
However, updating via wp-config.php usually has no effect, especially when the configuration in PHP Selector or MultiPHP is already set lower than the value you are using in wp-config. Therefore, this method is less recommended.
Simply edit the wp-config.php file in your WordPress installation, then add the following lines above the line /* That’s all, stop editing! Happy publishing. */
define('WP_MAX_UPLOAD_SIZE', '56M');define('WP_MAX_UPLOAD_FILE_SIZE', '56M');define('UPLOAD_MAX_FILESIZE', '56M');define('POST_MAX_SIZE', '56M');/* That's all, stop editing! Happy publishing. */Once added, the result will look something like this
Just like before, you can also check the maximum upload size via Media > Add new media file on the dashboard page
Option 4: Update upload_max_filesize via MultiPHP Editor
If you are using the cPanel control panel, you can increase the upload_max_filesize more easily via the upload_max_filesize page.
First, find and open the page MultiPHP INI Editor from your cPanel hosting
Once you are on the MultiPHP INI Editor page, select the domain for which you want to update the PHP version, then change the post_max_size and upload_max_filesize
columns. Make sure the post_max_size number is higher than or equal to upload_max_filesize. Because if it is lower, the maximum file size that can be uploaded will follow the post_max_sizesize, not upload_max_filesize.
After the update, you can check the size that can be uploaded via the WordPress dashboard
Option 5: Increase upload_max_filesize via PHP Selector
If your hosting supports PHP Selector, you can also use this method to increase the upload_max_filesize. However, if you use this method, the available values are already determined, for example 2MB, 4MB, 8MB, and so on.
To use this method, first open the page Select PHP Version from the cPanel you are using
After being on the PHP Selectorpage, make sure your domain is using PHP Selector and not using PHP Native
Once confirmed, you can now open the Options tab to change the upload_max_filesize
Now update post_max_size and upload_max_filesize according to the available values
After performing the update, you can check again the file size that you can upload to your WordPress
Option 6: Use a Plugin
Having trouble updating the files according to the previous options? You can also increase the upload_max_filesize using a plugin, for example with the Increase Maximum Upload File Size.
plugin. Once you have installed and activated the Increase Maximum Upload File Sizeplugin, you can then open the Settings > Increase Maximum Upload File Size page from the WordPress dashboard
From that page, you can then choose the maximum upload size according to the available options, for example changing it to 1GB
After the changes are set and saved, you can check again the maximum file size that can be uploaded to your WordPress
Those are some easy ways to fix The uploaded file exceeds the upload_max_filesize directive in php.ini in WordPress.
If you are using hosting or a control panel other than cPanel, you can try to perform the update via the .htaccess file, because updates via .htaccess are more often successful compared to other options.
COMMENTS
Loading...