‘Uploaded file exceeds the upload_max_filesize directive in php.ini’ is an error meaning the file you are uploading is larger than WordPress’s upload limit. To fix ‘Uploaded file exceeds…’ error you need to increase upload_max_filesize using config.php or php.ini file. You can find the instructions below.
This error can also be shown as a HTTP error in WordPress.
- What is uploaded file exceeds the upload_max_filesize directive in php.ini error?
- Fix uploaded file exceeds the upload_max_filesize directive in php.ini error
- Increase upload_max_filesize in WordPress
- Increase upload_max_filesize in cPanel
- Increase upload_max_filesize with FTP
- Increase upload_max_filesize with .htaccess file
- Increase upload_max_filesize in function.php file
What is uploaded file exceeds the upload_max_filesize directive in php.ini error?
Hosting providers limit your upload file size to protect the server. Upload_max_filesize code can be found in your php.ini file. Php.ini file is your server’s default PHP structure.
These limitations are mostly set by the hosting provider and you can see them by going to your WordPress dashboard, Media and clicking on Add New.
Fix uploaded file exceeds the upload_max_filesize directive in php.ini error
To fix this error, you need to increase the upload size in your php.ini file. There are many ways to increase the upload size, which we will discuss below:
Increase upload_max_filesize in WordPress
With an FTP client, connect to your server’s root directory, and paste the code below at the bottom of your wp-config.php file:
Now you have changed your upload size limit to 256 megabytes.
Increase upload_max_filesize in cPanel
If your host uses cPanel, by entering your cPanel you can simply make your changes to php.ini.
First, locate MultiPHP INI Editor. Then select your website, on the opened page. You can see several settings that can be edited. Scroll down to upload_max_filesize and change its value to your desired number.
Increase upload_max_filesize with FTP
As mentioned above, php.ini manages your server’s PHP structure. If your hosting provider allows you to access php.ini file, you can make the required changes to it.
With an FTP client, connect to your server and head over to your directory. If you can’t locate php.ini (or php5.ini) to edit it, then you can simply create a file with the same name and add the code below to it.
upload_max_filesize = 2M post_max_size = 3M memory_limit = 5M file_uploads = On max_execution_time = 300
If you are using XAMPP, Wamp or MAMP, you can locate the php.ini in:
Windows: C:/xampp/php/php.ini macOS: /private/etc/php.ini Linux: /etc/php.ini
Keep in mind, some hosting providers require a suPHP in .htaccess file to run the code that we mentioned. Make sure you add the code below to your .htaccess file:
<IfModule mod_suphp.c> suPHP_ConfigPath /home/yourusername/public_html </IfModule>
Make sure you change yourusername, with your actual path.
Configurations mentioned above may be different for different hosting providers. Therefore, to make sure they are indeed the right configurations for your server, you can simply contact your hosting provider or look at their forums.
Increase upload_max_filesize with .htaccess file
If your hosting provider doesn’t allow you to edit or create php.ini file, you can make some changes to your .htaccess file to change upload_max_filesize. To do so, connect to your server with an FTP client and open your main directory. Locate .htaccess file and add the codes below:
php_value upload_max_filesize 2M php_value post_max_size 3M php_value memory_limit 5M php_value max_execution_time 300 php_value max_input_time 300
If by adding the code above to your .htaccess file you receive an error from your server, it means that your server is running PHP on CGI and you are not allowed to edit .htaccess file. Delete the added codes to restore your website back to its original state.
Increase upload_max_filesize in function.php file
To fix upload_max_filesize error in WordPress, you can also add the code below to your functions.php file in your child theme:
@ini_set( 'upload_max_size' , '40M' ); @ini_set( 'post_max_size', '70M'); @ini_set( 'max_execution_time', '250M');
You can change the numbers above to the limitations that suit you.
If none of the methods above worked for you, you need to contact your hosting provider’s support team and notify them of the situation.
To make sure the methods above have worked, you can head over to your WordPress dashboard, media and click on add new and look for upload size limit. If the limit has changed from what it was to the number you have entered in your codes, then it means it has worked. If not, then you need to contact your hosting provider.
Keep in mind, if you are still having issues uploading your file to the website, you can use an FTP client to upload your files to the server. Because FTP doesn’t have any upload size limitations.