Logo

6 Ways to Fix Uploaded File Exceeds upload_max_filesize Error in WordPress

Try this guide with our instant dedicated server for as low as 40 Euros

the uploaded file exceeds

If you’re working with WordPress and encounter the error The uploaded file exceeds the upload_max_filesize directive in php.ini, you’re not alone. This error occurs when uploading large images, videos, plugins, themes, or any type of file to your WordPress site.

Luckily, resolving this error involves simple steps that adjust the file upload limits on your server. 

In this comprehensive tutorial, we will discuss six methods you can apply to fix the issue and ensure the WordPress site runs smoothly.

Table Of Contents

  1. 6 Ways to Fix Uploaded File Exceeds upload_max_filesize Error in WordPress
    1. The Prerequisites
    2. Method #1: Edit the .htaccess File in cPanel
    3. Method #2: Edit the .htaccess File using the Command Line Interface
    4. Method #3: Edit the wp-config.php File
    5. Method #4: Edit the wp-config.php File from the Command Line Interface
    6. Method #5: Edit the php.ini File
    7. Method #6: Contact the Host’s Support
  2. Conclusion
  3. FAQs

6 Ways to Fix Uploaded File Exceeds upload_max_filesize Error in WordPress

Let’s start with a short discussion on the underlying situation that causes this error.

There is a limit on how large a file you can upload to your website to minimize the load on the server resources. Uploading big files takes a long time and uses up bandwidth and storage space. This is akin to bulky furniture that might not fit or take up too much space in your room.

Your hosting provider sets this limit, which is controlled by a setting called upload_max_filesize in a file named php.ini.

We recommend finding the size of the file you can upload to your server by visiting your WordPress dashboard.

Click Media to expand the menu and select Add New.

Here, on our test server, you can upload files up to 10 MB. Unfortunately, it is impossible to change this limit in WordPress. However, you can change it by accessing your server.

We will now discuss the six easy ways to adjust the file size limit on your server. But first, take a quick look at the prerequisites for these methods.

upload new media

The Prerequisites

Before attempting to fix the file upload limit issue, ensure you have the following:

  • A working WordPress installation
  • Access to the command line interface or cPanel 
  • A user account with sudo privileges on the server

Method #1 Edit the .htaccess File in cPanel

Editing the .htaccess file through cPanel is one of the most straightforward methods to resolve the Uploaded file exceeds the upload_max_filesize directive in php.ini error. 

The process has the following steps.

Step #1: Access Your cPanel Account

Log into your cPanel account with administrator credentials. The path to this webpage usually has /cpanel at the end of your website’s URL. Some hosting providers provide a separate direct link for logging into the cPanel account.

Step #2: Open the File Manager

Click the File Manager in cPanel. This tool allows you to manage all the files on your server directly through a web-based interface.

Step #3: Navigate to the Root Directory

The .htaccess file you need to edit is typically located in the root directory of your WordPress installation. Usually, the file is located in public_html or www directories.

Step #4: Edit the .htaccess File

Locate the .htaccess file in the list of files. 

Note: Hidden files, like .htaccess, might not be visible by default. You may need to enable the show hidden files option in the File Manager settings to view the file.

Right-click on the .htaccess file and select Edit from the context menu. 

A text editor will open within your browser.

Scroll down to the end of the file and add the following lines:

php_value upload_max_filesize 64M

php_value post_max_size 64M

php_value max_execution_time 300


Here,

 php_value upload_max_filesize 64M instructs the server to increase the maximum file upload size to 64MB.

php_value post_max_size 64M increases the post size (which should be larger or equal to the upload size) to 64MB.

php_value max_execution_time 300 extends the maximum execution time to 300 seconds. This is useful for ensuring that the process doesn’t time out when uploading large files that take longer to process.

Once you add these lines, save the file using the editor’s Save button.

Step #5: Test the Changes

Return to your WordPress site and try uploading the file again. If the error was related to file size limits, it should now be resolved.

Method #2: Edit the .htaccess File using the Command Line Interface

Using the Command Line Interface (CLI) to edit the .htaccess file is a powerful alternative for users who prefer direct server access or do not have access to cPanel. Often, developers and more experienced users opt for this method of editing the .htaccess file.

The steps of the process are as follows: 

Step #1: Connect to Your Server via SSH

Establish a secure connection to your server. You can do this using an SSH client on Linux systems. If you’re using a Windows system, use an SSH client like PuTTY or the built-in SSH client in newer Windows versions.

Step #2: Navigate to the WordPress Root Directory

Once connected, navigate to the directory where your WordPress is installed. 

This directory is usually called public_html or www. Use the cd command to move between directories. For example, the command in this scenario would be similar to:

# cd /path/to/your/wordpress

Step #3: Open the .htaccess File in a Text Editor

Open the .htaccess file using a command-line text editor. On Linux systems, Nano and Vim are the common text editors. For this demonstration, we will use Nano.

# nano .htaccess

Step #4: Edit the File

Once the file is open in Nano, use the arrow keys to move the cursor at the end of the file. Add the following lines:

php_value upload_max_filesize 64M

php_value post_max_size 64M

php_value max_execution_time 300

Here, 

php_value upload_max_filesize 64M increases the maximum file upload size.

php_value post_max_size 64M increases post size to 64MB

php_value max_execution_time 300 increases the maximum execution time to 300 seconds.

Step #5: Save and Exit

Once the changes are made, save the file and exit the editor.

In Nano, you can do this by pressing CTRL + O to save the file, then CTRL + X to exit the editor.

Step #6: Verify the Changes

Browse your WordPress site and try uploading a file that previously triggered the error to see if the issue is resolved.

Step #7 Troubleshoot if Necessary

If the changes don’t seem to take effect, you may need to check for syntax errors in your .htaccess file. You should confirm that .htaccess overrides are allowed in your server configuration. 

Sometimes, server settings in Apache might ignore or override .htaccess settings. In such cases, consult your hosting provider or server administrator to resolve the problem.

Method #3: Edit the wp-config.php File

Editing the wp-config.php file is another effective way to address the Uploaded file exceeds the upload_max_filesize directive in php.ini error in WordPress. 

This approach involves adding a line of code that specifically increases the PHP memory limit. This method can indirectly affect file upload limits.

Here are the steps you can follow to modify wp-config.php:

Step #1: Access Your Hosting File Manager or FTP Client

Log in to your hosting account and open the cPanel File Manager.

Alternatively, connect to your server using an FTP client like FileZilla. This step is crucial as you’ll need direct access to your site’s root files.

Step #2: Locate the wp-config.php File

The wp-config.php is located in the root directory of your WordPress installation, along with wp-content and wp-admin files. It’s one of the core WordPress files.

 

Locate the wp-config.php File

Step #3: Backup the wp-config.php File

Create a backup copy of the original wp-config.php file. This is an important step in creating a safety net in case you need to revert the changes you make. You should download the backup file to your computer.

Step #4 Edit the wp-config.php File

Open the wp-config.php file in the text editor provided by your File Manager or the FTP client. 

Scroll to the bottom of the file, just before the line that says /* That’s all, stop editing! Happy publishing. */. 

Here, insert the following line:

@ini_set('upload_max_size' , '64M' );

ini_set

This line instructs WordPress to increase the PHP upload max size limit to 64MB, which can help accommodate larger file uploads.

Step #5: Save the Changes

Once you add the new line, save the file.

If you’re using a text editor in File Manager, click the Save button. Alternatively, if you opted for the FTP client, save the file on your computer and then upload it back to the server, replacing the old file.

Step #6: Verify the Changes

Go back to your WordPress site and try uploading the file again. If the memory limit was the problem preventing large file uploads, this adjustment should help.

Step #7: Check for Errors

If you continue to see the error, double-check the line you added to the file for typos. 

Also, ensure that your server’s PHP settings allow individual applications like WordPress to increase the memory limit. In some cases, hosting providers set a hard limit that cannot be overridden by making changes to wp-config.php.

Method #4: Edit the wp-config.php File from the Command Line Interface

For users, particularly DevOps engineers and sysadmin who are comfortable with command-line tools, editing the wp-config.php file via the CLI is a time savior. It offers a quick and efficient way to adjust important settings without navigating through a graphical user interface. 

Here are the steps involved in editing wp-config.php through CLI.

Step #1: SSH into Your Server

Establish a secure connection to your server using SSH.

If using key-based authentication, you need the server’s IP address, SSH username, and password or private key.

Step #2: Navigate to the WordPress Installation Directory

Once connected, change over to the directory where your WordPress is installed. This is typically found under the public_html or html directories. 

You can use the cd command to change directories:

# cd /path/to/your/wordpress

Step #3: Open the wp-config.php File

Open the wp-config.php file using your preferred text editor. Since we will use Nano, we will run the following command: 

# nano wp-config.php

Step #4: Edit the File

Open the editor and navigate to the line that reads /* That’s all, stop editing! Happy publishing. */. 

Here, add the following line BEFORE the above-mentioned line:

@ini_set('upload_max_size' , '64M' );

ini_set

This directive increases the PHP upload max filesize limit to 64MB within WordPress, which can help facilitate the processing of larger uploads by allowing WordPress to utilize more memory.

Step #5: Save the File and Exit the Editor

Once you have inserted the new configuration line, save your changes. 

In Nano, press CTRL+O to save the changes, followed by CTRL+X to exit the editor.

If using Vim, press ESC, type :wq, and press ENTER.

Step #6: Verify the Changes
To ensure your changes are active, try uploading a file through your WordPress dashboard to see if the upload_max_filesize error has been resolved.

Step #7: Troubleshoot Any Issues

If the problem still persists, chances are other PHP settings on your server are overriding the wp-config.php settings, or your hosting provider may have restrictions on memory usage that you cannot override. In such cases, contacting your hosting provider or checking server logs for any specific error messages can provide further insight.

Method #5: Edit the php.ini File

Modifying the php.ini file is one of the most direct methods of resolving the Uploaded file exceeds the upload_max_filesize error in WordPress. This configuration file controls the PHP settings on your server, and making changes to this file affects all applications running PHP, not just WordPress.

Follow these steps to make changes in php.ini directly:

Step #1: Locate the php.ini File

Note: The location of php.ini can vary depending on the server setup. Generally, it’s located in the etc directory of your server. Alternatively, you can use the File Manager in cPanel or Plesk. 

If you’re unsure about the file’s location, create a temporary PHP info file to find out the path. 

Create a new file called info.php in your WordPress root directory. Add the following PHP code:

<?php phpinfo(); ?>

Now, access this file via your browser. The typical URL of the file is http://yourdomain.com/info.php. The output displays php.ini location under the Loaded Configuration File section.

Step #2: Edit the php.ini File

Once you locate the php.ini file, edit it.

If you have access through a web interface like cPanel, navigate to the PHP settings section and open the file editor. Alternatively, if you are accessing via SSH, use a command-line editor like Nano. The command in this case will be:

# sudo nano /path/to/php.ini

Step #3: Modify the File Upload Limits

In the php.ini file, look for the following lines:

upload_max_filesize = 2M
post_max_size = 8M


Change the values to a higher number, like 64M, to increase the file upload capacity:

upload_max_filesize = 64M
post_max_size = 64M

Step #4: Adjust Maximum Execution Time

Large files require more time to upload. So, find the max_execution_time setting and increase its value to allow enough time for file upload. Note that the standard value is 30.

max_execution_time = 300

Step #5: Save Changes and Restart the Web Server

Once you make the changes, save the php.ini file. 

In many server environments, you need to restart your web server for the changes to take effect. If you have Apache as your web server, we recommend the following command:

# sudo systemctl restart apache2

Alternatively, if you have NGINX as the web server, run the following command:

# sudo systemctl restart nginx

Step #6: Verify the Changes

Once your server is back online, try uploading a file again in WordPress to see if the changes have resolved the issue.

Step #7: Check for Server-side Overrides

If the changes do not take effect, your hosting provider may have restrictions that override the local php.ini modifications. In such cases, you may need to contact your host’s support for assistance or use a local php.ini in your WordPress directory with the necessary changes.

Method #6: Contact the Host’s Support

If none of the above methods work, it’s time to contact your hosting provider’s support team. They can increase file upload limits and help resolve any underlying server issues.

Conclusion

Resolving the “uploaded file exceeds the upload_max_filesize directive in php.ini” error in WordPress is typically straightforward with the above methods. If you’re looking for a robust hosting solution that minimizes such issues, consider Redswitches Bare Metal Hosting Provider.

Known for its powerful servers and excellent customer support you can seamlessly upgrade your WordPress site and fix any error including uploaded file exceeds the upload_max_filesize directive in php.ini.

FAQs

Q. What is the “The Uploaded File Exceeds the upload_max_filesize Directive in php.ini” error in WordPress?

This error occurs when you try to upload a file to your WordPress website that exceeds the limit set by the upload_max_filesize directive in the php.ini file.

Q. How can I fix the uploaded file that exceeds the upload_max_filesize directive in the php.ini error in WordPress?

You can fix this error by increasing the upload_max_filesize directive in the php.ini file or by using other methods like modifying the .htaccess file or using a plugin.

Q. What should I do if I get the error message “The Uploaded File Exceeds the upload_max_filesize Directive in php.ini” in WordPress?

If you encounter this error message, you need to either increase the upload_max_filesize directive in the php.ini file or check other methods to resolve the issue.

Q. How can I increase the upload_max_filesize directive in php.ini to fix the uploaded file exceeds error?

You can increase the upload_max_filesize directive in the php.ini file by editing the file and changing the value to a higher limit, such as “php_value upload_max_filesize 64m“.

Q. Can I fix the uploaded file that exceeds the upload_max_filesize error via FTP?

Yes, you can fix this error via FTP by accessing the php.ini file and modifying the upload_max_filesize directive to increase the maximum file size for uploads.

Q. What other ways can I try to upload files larger than the maximum upload file size in WordPress?

Apart from modifying the php.ini file, you can use plugins that allow larger file uploads or modify the .htaccess file to increase the upload limits.

Q. How can I fix the upload_max_filesize error if my host uses cPanel?

If your host uses cPanel, you can try modifying the PHP configuration settings through cPanel or contacting your hosting provider for assistance in increasing the upload_max_filesize limit.

Try this guide with our instant dedicated server for as low as 40 Euros