Introduction
If you are a WordPress user, you may have encountered the error “The uploaded file exceeds the upload_max_filesize directive in php.ini” when trying to upload a file to your WordPress site. This error occurs when the file size of the file you are trying to upload exceeds the maximum file size limit set in the php.ini file. Fortunately, this error can be easily fixed by increasing the upload_max_filesize directive in the php.ini file. In this article, we will discuss how to fix this error by increasing the upload_max_filesize directive in the php.ini file.
How to Fix The Uploaded File Exceeds the upload_max_filesize Directive in php.ini. Error in WordPress
1. Connect to your website using an FTP client.
2. Locate the php.ini file.
3. Edit the php.ini file and increase the upload_max_filesize directive.
4. Save the changes and upload the file back to your server.
5. Refresh your WordPress site and try uploading the file again.
Introduction
The Uploaded file exceeds the upload_max_filesize directive in php.ini error in WordPress, occurs when uploading large files, themes, or images. The issue is the result of a server-side setting that limits file sizes.
This guide provides six (6) solutions on how to adjust the appropriate parameters and resolve the file size error.
Prerequisites
- A working WordPress installation
- Access to the server that hosts the WordPress installation (local or SSH)
- If you are working from a client system, a file manager (or cPanel)
- A user account with sudo privileges
- Access to a command-line/terminal window (optional)
6 Ways to Fix Uploaded File Exceeds upload_max_filesize error in WordPress
Use the WordPress dashboard to check your current maximum upload file size. Select the Media > Add New option, as shown in the image below.
In this example, the maximum file size is limited to 232 MB. It is not possible to change this setting using WordPress. We provided 6 simple solutions on how to configure maximum file size on your server.
Option 1: Edit the .htaccess File (cPanel)
1. Open cPanel and launch the file manager.
2. Right-click the .htaccess file, then click edit.
Note: If you are not able to locate the .htaccess file, you may need to click Settings in the upper-right corner and check the box to show hidden files.
3. Explore the file and find the line php_value upload_max_filesize. Edit the line to look as follows:
php_value_upload_max_filesize 256M
This instruction changes the server-side limit on the size of the file you’re allowed to upload to 256 MB.
4. Save the changes and exit the file.
Option 2: Edit the .htaccess File using Command Line Interface
1. Access the server that hosts your WordPress site.
2. Enter the following command in your Command Line Interface to access the WordPress directory:
cd /path/to/wordpress
Note: The /path/to/wordpress is an example. You need to enter the correct path to your WordPress directory.
3. Open the .htaccess file with a text editor of your choice. In this example, we used the nano text editor:
sudo nano .htaccess
4. Explore the file and find the line php_value upload_max_filesize. Edit the line and define the size you need:
php_value_upload_max_filesize 256M
This instruction changes the server-side limit on the size of the file you are allowed to upload to 256 MB.
5. Save the changes and exit the file.
Option 3: Editing wp-config.php File
This method changes the limits on the PHP file size by editing the wp-config.php file directly:
1. Access the public_html folder using cPanel.
2. Find the wp-config.php file. Right-click the file and select the edit option.
Scroll nearly to the end of the file and find for the following comment line:
/* That’s all, stop editing! Happy blogging. */
3. Add the following code just above that line:
@ini_set('upload_max_size' , '256M' );
4. Save the file and exit. Try to upload your file again.
Option 4: Edit the wp-config.php File from Command Line Interface
1. Access the server that hosts your WordPress site.
2. Enter the following command and access the WordPress directory:
cd /path/to/wordpress
3. Open the wp-config.php file with a text editor of your choice.
sudo nano wp-config.php
4. Find for the following comment line:
/* That’s all, stop editing! Happy blogging. */
5. Add the following line just above:
@ini_set('upload_max_size' , '256M' );
6. Save the file and exit.
Option 5: Edit php.ini File
The php.ini file is a configuration file for PHP variables. The following steps show you how to edit the php.ini file:
1. Log into your server hosting the WordPress site.
2. Access the Command Line Interface, and enter the following:
cd /etc/php/7.0/cli
Note: If you’re running a different version of PHP, make sure to replace 7.0 with the version you are currently using.
3. Use a text editor to open the php.ini file:
sudo nano php.ini
4. Locate the following line:
upload_max_filesize = 100M
5. Replace 100M with a higher value in megabytes. (256 MB for example)
This file allows you to configure other settings as well:
- memory_limit 256M – Sets the max amount of memory a script can use.
- post_max_size 32M – Sets the max size for the total of the POST body data.
- max_execution_time 600 – Max time, in seconds, that a script is allowed to run.
- max_input_time 900 – Max time, in seconds, that a script is allowed to parse input data.
6. Save the file and exit.
Test your file upload in WordPress – the issue with file size is now resolved.
Option 6: Contact Host’s Support
It is not uncommon for hosting companies to set limitations on the settings clients can edit themselves. Depending on your particular hosting company, you might not be able to perform some of the actions described in the previous steps.
In those cases, it might be necessary to contact your host’s support services. Most hosts perform this type of configuration as part of their standard service.
Conclusion
Now you know how to fix the error “The uploaded file exceeds the upload_max_filesize directive in php.ini.” in WordPress. This tutorial covered 6 different methods to increase the maximum file upload size.
Regardless of the chosen method, by following these simple instructions, you are now able to define the maximum file size when uploading files to your website.
How to Fix The Uploaded File Exceeds the upload_max_filesize Directive in php.ini Error in WordPress
If you are a WordPress user, you may have encountered the error “The uploaded file exceeds the upload_max_filesize directive in php.ini” when trying to upload a file to your WordPress site. This error occurs when the file size of the file you are trying to upload is larger than the maximum file size allowed by your server. Fortunately, this error can be easily fixed by increasing the upload_max_filesize directive in your php.ini file.
Steps to Fix the Error
- First, you need to locate your php.ini file. This file is usually located in the root directory of your WordPress installation. If you are using a shared hosting provider, you may need to contact your hosting provider to locate the file.
- Once you have located the php.ini file, open it in a text editor. You can use any text editor, such as Notepad or TextEdit.
- Look for the line “upload_max_filesize” and change the value to the size you want. For example, if you want to allow files up to 10MB in size, you would change the value to “10M”.
- Save the file and upload it back to the server. You may need to contact your hosting provider for instructions on how to upload the file.
- Finally, you need to restart your web server. This can usually be done by logging into your hosting control panel and restarting the web server.
Once you have completed these steps, you should be able to upload files of any size to your WordPress site without encountering the “The uploaded file exceeds the upload_max_filesize directive in php.ini” error.