How to Increase the Max Upload File Size in WordPress

How to Increase the Max Upload File Size in WordPress

Techesium content is free. When you purchase through links on our site, we may earn an affiliate commission. Learn More

No matter where you host your WordPress site, there’s always a chance that you may need to tweak some specific server settings before uploading large files or processing large amounts of data. The most common issue new WordPress sites face is a file size limit for upload: when you try to upload a pretty large file to a website, you may get an error stating that your file exceeds the maximum upload size for this site or something similar.

Often upload errors occur when you try to upload these files:

  • Large media files, such as photos, videos, and music
  • WordPress plugins
  • WordPress themes

Thankfully, such an issue is easily fixable on most WordPress hosting providers. In this guide, you’ll learn to increase your website’s max upload file size using a plugin and server config.

Check the Maximum Upload File Size Limit

Before we increase the maximum file upload size limit, it’s a good idea to check the current limit set by default on your server.

Log in to your WordPress dashboard, go to Media → Add New, and find a note specifying the current maximum upload file size – that’s the limit we might need to increase.

WordPress Media Max Upload File Size

Increase the Maximum Upload File Size Limit With a Plugin

The easiest way to increase the maximum upload file size limit is to use a WordPress plugin. While you can choose any plugin to increase the limit, I’ll use the Big File Uploads plugin.

To install the plugin, go to Plugins → Add New, search for Big File Uploads, click Install Now, and Activate.

WordPress Install Big File Uploads

After that, head over to Settings → Big File Uploads and look for the Maximum Upload Size setting: I recommend setting the size to 256 MB. If you plan to upload large files, such as video files, increase the size to as much as necessary.

WordPress Big File Uploads Settings

If this or other methods in this article don’t work for you to increase the maximum upload size, you should consult your hosting provider. You might not be able to increase the size because you use shared hosting or your hosting provider doesn’t allow it.

Increase the Maximum Upload File Size Limit With the Theme File Editor

To avoid installing additional WordPress plugins, you can manually increase the maximum upload file size limit using your theme’s functions.php file.

To edit the functions.php file, go to Tools → Theme File Editor, and under Theme Files, click Theme Functions (functions.php).

Copy and paste the following code snippet into the beginning of the file content, below the <?php opening tag:

@ini_set( 'upload_max_size' , '256M' );
@ini_set( 'post_max_size', '256M' );
@ini_set( 'max_execution_time', '800' );

Here the upload_max_size variable sets the maximum upload file size a user can upload to the server, and post_max_size sets the maximum size of POST data accepted. Finally, the max_execution_time variable specifies the number of seconds a script is allowed to run.

I recommend editing the functions.php file on a child theme, so your changes won’t disappear when your main theme gets updated. Usually, you can download a child theme from your theme’s official website. For example, if you use the Astra theme, you can download and install its child theme from here.

Increase the Maximum Upload File Size Limit on a Server

You can choose a more advanced way to increase the maximum upload file size limit by editing your server settings. This way, you set permanent settings on a server, so you don’t need to do any modifications in WordPress.

Increase the Size by Editing PHP Configuration Settings

Depending on your hosting provider, you may be able to increase the upload size by editing PHP configuration settings in your hosting’s control panel, such as cPanel. However, if there’s no control panel available, you might be able to edit the settings using different methods, e.g., SFTP client or SSH connection.

To change PHP settings on a server, we need to find and edit the php.ini file. Look below for the most common places where you may find this file.

On the Apache server:

/etc/php/7.4/apache2/php.ini

On the NGINX or Apache server with PHP-FPM:

/etc/php/7.4/fpm/php.ini

Depending on your server’s operating system, configuration, and installed versions of packages, the actual location of the php.ini file might differ. For example, if you have a different PHP version running on your server than 7.4, let’s say, 8.0, then the location will be different, e.g., /etc/php/8.0/apache2/php.ini.

If you have trouble locating the php.ini file, you can try running this command in your server’s terminal:

sudo find / -name php.ini

After running the command, you should see a list of php.ini files with their locations.

To edit the php.ini file, you can open it with the vi editor:

sudo vi /etc/php/7.4/apache2/php.ini

OR, if you’re not familiar with the vi editor, you can use the nano editor instead, which is easy to use and should already be installed on most Linux servers by default, such as Ubuntu:

sudo nano /etc/php/7.4/apache2/php.ini

Depending on your server’s operating system, configuration, and installed versions of packages, the actual location of the php.ini file might differ. For example, if you have a different PHP version running on your server than 7.4, let’s say, 8.0, then the location will be different, e.g., /etc/php/8.0/apache2/php.ini.

If you’re on shared hosting, your hosting provider might not allow you to edit the file. In such a case, you can try to create the file in your WordPress installation’s root directory, e.g., /var/www/html using the FTP/SFTP client, such as FileZilla. Or, if possible, you can do that using the terminal with any text editor, such as vi:

sudo vi /var/www/html/php.ini

The command above opens the vi editor in the /var/www/html directory, where the editor will save your file.

Then, add the following code snippet to the file and save the changes:

upload_max_size = 256M
post_max_size = 256M
max_execution_time = 800

Next, if you use the NGINX server, specify the upload size there, too – you can set it globally in all locations in the nginx.conf file. To do this, open the file with the following command:

sudo vi /etc/nginx/nginx.conf

Then, add the client_max_body_size variable in the http {…} block:

http {
      ...
      client_max_body_size 256M;
}

Finally, after saving the changes, you need to restart your server.

If you use the Apache server, run:

sudo systemctl restart apache2.service

OR, if your site is running on CentOS/RHEL:

sudo service httpd restart

If you use the NGINX server, run:

sudo systemctl restart nginx.service

If you use PHP-FPM, run:

sudo systemctl restart php7.4-fpm.service

Replace the php7.4-fpm.service version with your actual PHP version. If you get any error that the service doesn’t exist on your system, try replacing it with php-fpm.service instead (without PHP version).

Increase the Size by Editing the Apache Server Configuration Settings

If earlier methods don’t work for you, you can try to change PHP settings using the .htaccess file.

You can easily edit the file using the FileZilla Client: connect to your server through SFTP, navigate to the WordPress root directory, find the .htaccess file, right-click on it, and choose the View/Edit option.

Then, add the following code snippet at the bottom of the file and save it:

php_value upload_max_size 256M
php_value post_max_size 256M
php_value max_execution_time 800

Alternatively, to edit the file via a terminal, you can open it with the vi editor:

sudo vi /var/www/html/.htaccess

Your changes should take effect as soon as you save the .htaccess file. However, if you don’t see any changes for some reason, try restarting the Apache service using a terminal with the following commands below.

To restart the Apache service on Debian based Linux operating systems, e.g., Ubuntu:

sudo systemctl restart apache2.service

To restart the Apache service on CentOS/RHEL:

sudo service httpd restart
Picture of Rimantas Jurgelevičius

Rimantas Jurgelevičius

Rimantas Jurgelevičius is the founder and owner of Techesium. He's interested in web development, cloud computing, and other online technologies and aims to provide easy-to-follow and detailed tutorials for others.

Related Posts

Leave a Comment

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

Scroll to Top