Home
/
Website Help
/
How to fix “the uploaded file exceeds the upload_max_filesize directive in php.ini.” error

How to fix “the uploaded file exceeds the upload_max_filesize directive in php.ini.” error

Seeing “the uploaded file exceeds the upload_max_filesize directive in php.ini.” while uploading a file to your WordPress site? Worry not, this is a common hiccup you can quickly fix with a few straightforward steps.

This error generally appears when the file you try to upload tops the maximum file size limit allowed in the server’s configuration file, php.ini. Thus, increasing the upload max filesize value for your WordPress is the most practical solution.

In this article, we’ll show you how to bump up the value for the upload_max_filesize variable in php.ini. Read on to find out what causes the error and the 3 methods for increasing the value of this PHP variable.

This error indicates that the file you are uploading surpasses the maximum file size specified in the server’s configuration file – php.ini.

You may encounter the error message “the uploaded file exceeds the upload_max_filesize directive in php.ini.” when uploading a file to your site.

Screenshot of the Media Library in WordPress, showing the error the uploaded file exceeds the upload_max_filesize directive in php.ini

In short, this means that the error stems from an insufficient default value set in the php.ini file, not in WordPress itself.

The php.ini file is the default server configuration file for running PHP-based applications like WordPress. It defines parameters like upload size, file timeouts, resource limits, etc.

Before starting up, the PHP server checks the php.ini file for these directives and applies them to the server’s configuration. As uploading large files consumes lots of server resources, the server limits the maximum file upload size to prevent timeouts.

How to fix “the uploaded file exceeds the upload_max_filesize directive in php.ini.”

To fix the upload max filesize error, you need to increase the upload_max_filesize value within your website files. Do this by editing your WordPress site’s:

  • php.ini,
  • the wp-config.php,
  • or the .htaccess file.

If the file you’re trying to upload outstrips the maximum size limit, you can top this limit up by using any of these 3 methods below.

3 Methods to modify the upload_max_filesize value

Here, we’ll show you how to fix the upload max filesize for your WordPress by setting a higher value by editing your php.ini, wp-config.php, or .htaccess file.

The upload_max_filesize default value is set to 256MB for all SiteGround servers. The value is permanent for shared hosting plans. It can be increased further only on Cloud servers upon the client’s request.

Method 1. Increase the upload_max_filesize in php.ini

Increase the upload_max_filesize directly from your hosting’s File Manager. This is the easiest way to go, minding that this is a quick fix.

Alternatively, you can do that using an FTP or SSH connection. Find more information for each approach below.

Using File Manager

To raise the upload_max_filesize value for your site, you can modify the php.ini file in your File Manager. Navigate to the root folder for your WordPress (public_html) and locate the php.ini file. Edit the php.ini file when you find it and set values, as shown in the screenshot below.

If you can’t find a php.ini file, you can simply create the file and paste the snippet inside.

upload_max_filesize = 256M
post_max_size = 256M
Screenshot of the upload_max_filesize variable set in the php.ini via File Manager

Once you’ve adjusted the values of the variables, as in the screenshot above, hit the Save button. Then, to ensure the changes are in effect, clear your site cache and browser cache.

Retry to upload the file you intended to and see if you are still getting the upload max filesize error.

Via FTP

You can also edit the php.ini via an FTP connection. To do this, you must have an FTP account and use your credentials to connect through your chosen FTP client. For this example, we’ll use the FileZilla FTP client.

  1. Enter your login information to establish the connection
  2. Once you are connected, expand the public_html folder.
  3. Find the php.ini file listed in the FileZilla screen below
  4. Right-click to select the View/Edit option. FileZilla will ask you which
    Screenshot of editing the php.ini via FTP access to resolve the uploaded file exceeds the max_upload_filesize directive in php.ini
  5. Paste the same code snippet from the previous section in your php.ini file.
  6. Then confirm the changes and allow FileZilla a few seconds to upload the new file version.
    Screenshot of Confirming the changes to the php.ini file and uploading it back to the server

When done, try uploading the file again after clearing all caches. Then you can try uploading the intended file again.

Using SSH

A more advanced option is to edit the php.ini via SSH connection. Follow the steps below to increase the upload_max_filesize.

  1. Establish the SSH connection from your computer to the server.
  2. Access the root folder for your WordPress site by executing the following command.
    cd /path/to/your/wordpress

    In our example, the website is testsgdomain.com, so the root folder path is:

    cd /www/testsgdomain.com/public_html/
  3. Open and edit the php.ini file using your preferred text editor.
    nano php.ini
  4. Paste the following line and save the changes in the file.
    upload_max_filesize = 256M
  5. Clear your caches and try uploading the file again.

If you’ve followed the steps correctly, “the uploaded file exceeds the upload_max_filesize directive in php.ini.” in your WordPress should be resolved.

Method 2. Modify the wp-config.php file

Another way to solve the “uploaded file exceeds the upload_max_filesize directive in php.ini.” in WordPress is by editing the wp-config.php file. You can choose the most suitable approach for increasing the upload filesize – using File Manager, FTP, or SSH access.

For this example, we’ll use the File Manager to apply the changes in the wp-config.php.

  1. Access your File Manager from your hosting space.
  2. Locate the wp-config.php in your WordPress root directory.
  3. Open the file for editing with the File Manager’s text editor.
  4. Paste the code snippet from below in the wp-config.php
    @ini_set('upload_max_size' , '256M' );

     

    Screenshot showing how to edit the wp-config.php via File Manager

    Make sure to paste the snippet before the “That’s all, stop editing! Happy publishing.” line.

  5. Save the changes made in the wp-config.php
  6. Clear your caches and retry uploading the file you intended to initially.

That’s it! The “uploaded file exceeds the upload_max_ filesize directive in php.ini” error should be solved.

Method 3. Edit the .htaccess to increase the upload_max_filesize value

The third method to increase the upload_max_filesize value is by modifying the .htaccess file of your WordPress.

For this method, we’ll connect via FTP using FileZilla to raise the upload_max_filesize value in the .htaccess.

  1. Access your hosting space via FTP using your preferred FTP client
  2. Expand the public_html folder by clicking on it to see the files it contains.
  3. Locate the .htaccess file in the screen box showing the file listing.
  4. Select the .htaccess file and choose to View/Edit the file with a right-click to expand the options menu.
    Screenshot of editing the .htaccess file via FTP to fix the upload_max_filesize value
  5. Confirm opening the file with your default text editor.
  6. Paste the code piece at the end of the file.
    php_value upload_max_filesize 256M
    php_value post_max_size 256M
  7. Save the changes made to the file.
  8. Confirm that you want the altered .htaccess file uploaded back to the server.
    Screenshot of how to confirm the changes and upload the .htaccess back to the server via FTP

At SiteGround, this snippet will only work if your site uses our Ultrafast PHP setup. Using a php_value directive in the .htaccess file of a Standard PHP configuration will result in an Internal Server Error 500, as this is not a compatible option.

Given that your type of PHP setup allows it, “the uploaded file exceeds the upload_max_filesize directive in php.ini.” error should be fixed.

Get in touch with your web hosting support

In case you’ve tried everything so far and the upload max filesize error persists – contact your hosting service support for help.

SiteGround clients can reach out to our Support Team at any time. We’ll be happy to help troubleshoot and resolve the issue.

Additionally, Cloud server users can request an increase in the default upload_max_filesize value.

What causes the “uploaded file exceeds the upload_max_filesize directive in php.ini.” error in WordPress?

In WordPress, the “the uploaded file exceeds the upload_max_filesize directive in php.ini.” error can occur when uploading a file larger than the file size allowed in php.ini. That can happen for various reasons, such as uploading large-sized files. Another cause can be corrupted plugins and themes or low limits set on a server level.

In this section, we’ll outline and explain the most common causes for the upload max filesize error, so keep reading.

Oversized file uploads

When uploading a file to WordPress, the server uses the maximum filesize limit set in php.ini. If the file surpasses this limit, you get the “the uploaded file exceeds the upload_max_filesize directive in php.ini.” error.

Oversized file uploads are a common cause of this error. More specifically, large-size files are high-resolution images, large video files, or complex documents.

To solve this problem, increase the upload_max_filesize for your WordPress site or split the upload in chunks (if applicable).

Low value for upload_max_filesize in php.ini

A low value for the upload_max_filesize directive in php.ini can cause the “the uploaded file exceeds the upload_max_filesize directive in php.ini.” in WordPress. Usually, servers are configured to reject files larger than the limits in the php.ini file.

Thus, if the value for upload_max_filesize is too low, it can prevent you from uploading files exceeding this limit. Even if what you’re uploading is not so significant in size.

To fix this issue, you can increase the value for upload_max_filesize in php.ini to allow larger file uploads.

Plugin or Theme Conflicts

In WordPress, corrupted plugins or themes can also trigger the “the uploaded file exceeds the upload_max_filesize directive in php.ini.” error.

Plugins and themes are essential to the website’s functionality and design. However, they can cause conflicts that affect the website’s performance if they are outdated or incompatible. Such conflicts can cause the “uploaded file exceeds the upload_max _filesize directive in php.ini” for WordPress plugins and themes.

Additionally, some plugins or themes require larger file uploads than what is allowed by the server’s configuration file. If the file is larger than the php.ini limit, PHP generates an error message to prevent the upload from finishing.

To fix this, either increase the upload_max_filesize value or check if any plugins or themes are causing the problem. If so, you should update or disable them accordingly.

Conclusion

The “the uploaded file exceeds the upload_max_filesize directive in php.ini.” error is a common issue when uploading a file larger than the limit. The solution for this error is to increase the value of the upload_max_filesize variable.

In this guide, we showed you the steps to do that in 3 different ways. You can quickly increase the max upload filesize and upload your files by following them.

Share This Article