At some point during your WordPress career, you’ll need to upload a large theme or image to your website. If you’re using a reputable host, there shouldn’t be any problem. However, some providers may hit you with an Uploaded file exceeds the upload_max_filesize directive in php.ini error instead.

Despite its almost comically large name, this error isn’t as dire as it sounds. To put it simply, the problem is that your server is limiting your upload file size, which is something it does to keep things running smoothly. The good news is that if you know your way around WordPress’ file system or your back end, fixing this error isn’t difficult.

In this article, we’re going to talk a bit more about what this error means, and then we’ll teach you three ways to fix it. Let’s get to it!

What the Uploaded file exceeds the upload_max_filesize directive in php.ini Error Means

As we mentioned earlier, this error often pops up when your web host sets low filesize limits for its users. This means that each time you try to upload an image or a theme to WordPress, the platform checks if it can process them. If they’re larger than your server’s filesize limit, the error in question will pop up on your dashboard:

The filesize limit error.

Tweaking the filesize limit for a server isn’t overly complicated. In most cases, all it takes is adding or changing a few lines within specific files, and you’re good to go. However, some hosts don’t do this, as it’s open to abuse that can impact service for other users. In other words, this is mainly an issue if you’re using shared hosting, which is when you assign multiple people to a single server with resources they share.

To be fair, most web hosts set reasonable filesize limits. However, it’s likely that at some point you’ll need to upload a large file to your website, for one reason or another. If that’s the case, you can either try to compress it, ask your host to increase its limit, or tweak the setting yourself.

The only problem is that shared hosting users don’t usually have the necessary permissions to tweak their filesize limits. This means you may have to upgrade to a plan that gives you full control, such as one using a Virtual Private Server (VPS). These types of plans set you up with a virtual computer you can configure any way you want without affecting other users, and they’re usually cost-effective.

Before we talk about how to fix this error, it’s important to note that 000Webhost users don’t have to deal with this problem. Even though we’re the best value host around, we provide high filesize limits for our WordPress users to avoid giving you any headaches.

3 Ways to Fix the Uploaded file exceeds the upload_max_filesize directive in php.ini Error in WordPress

For this section, we’re going to introduce you to three ways to alter your WordPress installation so it supports larger upload sizes. Since we’re going to be making changes to important WordPress files, you should back up your website before you get started.

If you’re a 000Webhost user, you can create a backup of your site with a few clicks using the All-In-One WP Migration plugin, which we include with every installation. However, if you’re using another web host, you can go ahead and install the plugin on your own and use it as well. Just remember to save your backup somewhere you’ll remember, then move on to method number one!

1. Modify Your wp-config.php File

Before you roll up your sleeves, it’s worth mentioning that both this and the next method may not work depending on your host. For these sections, we’re going to tweak WordPress’ internal filesize limit. However, if your web host has a low filesize limit set on your server configuration files, these changes won’t override that setting. If you run into any issues, it’s worth asking your host directly if there’s anything they can do to help.

Moving on – your wp-config.php file includes a lot of your WordPress website’s primary settings, such as database information. To access it, you’ll need to get to your website’s back end using File Transfer Protocol (FTP), which enables you to send files back and forth securely from your server. To do so, you’ll need a  client such as FileZilla and your FTP credentials.

If you’re a 000Webhost user, you can find the latter by logging in to your account and going to the Settings > General page. Inside, you’ll find your credentials next to the FTP details heading:

Your FTP login credentials.

Keep this tab open for now, since you’ll need to copy your Host Name and Username in a minute. As for your password, it should be the same one you used to log into your account. Now install the FileZilla client and open it when it’s ready. You’ll see three empty fields at the top of your FileZilla window, named HostUsername, and Password. Those correspond to your 000Webhost FTP credentials:

Accessing your website via FTP.

Click on the Quickconnect button after you fill in those three fields, and wait for the client to establish a connection to your server. When it succeeds, a list of folders will show up in the lower right corner of the screen:

The public_html folder.

To locate and access your wp-config.php file from this point, follow these instructions in order:

  1. Open your public_html folder.
  2. On the next screen, scroll down until you locate the wp-config.php file.
  3. Right-click on the file and choose the option that says View/Edit.

Now FileZilla will download a copy of wp-config.php to your computer and open it using your default text editor, meaning you can make any changes you want. Scroll to the bottom of the file and look for the line reading /* That’s all, stop editing! Happy blogging. */. Once you find it, paste the following code right above it:

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

Save the changes to wp-config.php now and FileZilla will ask you if you want to replace the file on your server with the copy you just updated. Say yes and that’s it! What you just did was tell WordPress to set the max filesize for your uploads to 100 MB. Chances are you won’t ever need to upload a file that large, but it doesn’t hurt to give yourself a little breathing room!

2. Tweak Your .htaccess File

In practice, this method is very similar to the first one. The only difference is that this time, you’re going to change your .htaccess file, which contains configuration instructions for your server. To make changes to it, you’ll need to use your trusty FTP client once more. If you skipped method number one, go back for a second and read our instructions on how to find your FTP credentials and use FileZilla.

When you’re ready, access your website via FTP once more. When you establish a connection and see the public_html folder, follow these instructions:

  1. Open your public_html folder.
  2. On the next screen, look for the .htaccess file.
  3. Right-click on the file and hit the Download option.
  4. Right-click on the file again and choose the button that says View/Edit.

In this case, you downloaded a copy of .htaccess to your computer, which you can use as a backup later in case something goes wrong. Making changes to .htaccess is a delicate process since the wrong setting may prevent you from accessing your WordPress site at all, so it pays to be safe.

With that in mind, here’s the single line of code you should add to .htaccess to increase WordPress’ filesize limit:

php_value upload_max_filesize 100M

As with the first method, you want to add this line of code before the end of the file. In this case, you should place it above the line reading # END WordPress. Now save the changes to .htaccess. When FileZilla asks you if you want to upload your new version, say yes.

At this point, you should try accessing your dashboard to see if everything’s working fine. If it is, try uploading the file that gave you problems earlier to check if the changes took hold. If they didn’t, it’s time to bring out the big guns with method number three.

Finally, if you run into any problems with your website after changing your .htaccess file (such as not being able to access it), you can always restore the backup you downloaded earlier. To do that, locate the .htaccess file on your computer using FileZilla:

Your local copy of the htaccess file.

When you find it, make sure you’re connected to your server and are currently within the public_html file. Then, right-click your local copy of .htaccess and hit the Upload button. FileZilla will ask if you want to override the copy of your server, to which you should answer yes. Afterward, your site should be back to normal!

3. Alter Your php.ini File

As you may have noticed, php.ini is the very same file the error in question mentions. It stands to reason that the quickest way to increase your filesize upload limit would be to edit it directly. That’s partly true, but as we mentioned earlier, 000Webhost users don’t usually have access to this file.

On the other hand, if you’re using VPS or another type of hosting plan that gives you full access to your back end and its files, you can alter php.ini. The best way to do this is to use your FTP client (yet again!) and log in to your server. Once you’re in, follow these instructions:

  1. Look for your /etc directory and access it.
  2. Look for and enter the /php subdirectory.
  3. Inside, there might be more than one folder depending on which version of PHP your website is using, so look for the one with the highest number, such as /7.0.
  4. Find the /cli folder within and open it.
  5. Look for the php.ini file, right-click on it and choose the View/Edit option.

To recap, so far here’s the route you should have traveled /etc/php/7.0/cli/php.ini. Right now, the php.ini file should be open using your local text editor, so go ahead and look for the line that reads:

upload_max_filesize = X

To be clear, the X in this case is just a placeholder for whichever value your server is configured to support. All you need to do now is replace that value with the one you want, like this:

upload_max_filesize = 100M

Just in case, there are a few other lines you’ll also want to edit while you’re in here. For example:

max_execution_time = X
max_input_time = X

The first line tells your server how long it has to upload a file before the connection ‘times out’. When that happens, the upload will be interrupted and you’ll need to start from zero. Usually, this limit is set to something such as five-ten minutes, but you need to indicate that time in seconds. As for the max_input_time setting, it has to do with how long your server has to run a script. Since you’re going to upload larger files now, it makes sense to increase both limits accordingly:

max_execution_time = 600
max_input_time = 600

In this example, we set both limits to ten minutes, which should give you plenty of time to upload large files unless your internet connection is having issues. When you’re done, remember to save the changes to php.ini, confirm that you want to override the existing copy on your server, and you’re ready to go. Now try uploading whichever file gave you problems the first time around – the process should go smoothly now.

Conclusion

The Uploaded file exceeds the upload_max_filesize directive in php.ini error can be annoying, but it’s not complicated to fix. In fact, the error itself is downright helpful in the sense it provides you with all the information you need to troubleshoot it. That’s very much unlike other errors, such as the 502 bad gateway message, for example.

If you’re using 000Webhost, you shouldn’t run into this error since we don’t set artificially low limits for our users’ uploads. However, if the message pops up while you’re using another host, here are three ways to fix it:

  1. Modify your wp-config.php file.
  2. Tweak your .htaccess file.
  3. Alter your php.ini file.

Do you have any questions about how to fix the file upload size error in WordPress? Let’s talk about them in the comments section below!

2 Comments

  1. Prabhu Ganesh

    Hi
    This is Prabhu. i’m a web developer and work with wordpress. this article about how to fix the uploaded file exceeds the upload_max_filesize directive in php.ini Error is really helpful. Thanku

    Reply
    • Will Morris

      No problem Prabhu. Glad you found it helpful

      Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

  • php
  • my sql
  • intel
  • cloudlinux
  • nginx
  • cloudflare
  • wordpress