WordPress CMS supports a large number of hooks using plugins, themes, etc. But when it limits you to perform some function due to file size of the plugin, plugin files like backups, themes or video, etc. In that case, you’ve to increase the file upload size limit.
This tutorial article will discuss how we can increase the file upload size limit using function.php, .htaccess, php.ini, nginx.conf (nginx).
Increase Maximum file upload size in WordPress
You can increase the upload size limit of your WordPress application using various methods that allow you to upload large files to your website.
Using Theme Function file function.php
@ini_set( 'upload_max_size', '64M');
@ini_set( 'post_max_size', '64M');
@ini_set( 'max_execution_time', '300');
You can add the following lines in the function.php file to increase the file size. In the above command, the maximum file size is 64MB. You can change this value to increase the limit, such as 512M for 512MB and 1G for 1GB.
using php.ini method
You can increase file upload size, maximum post size, memory limit using php.ini in Apache or NGINX. php.ini can be located in the root directory of the application.
upload_max_filesize = 64M
post_max_size = 64M
memory_limit = 512M
Find the above command and replace it according to your need, like search upload_max_filesize and change the values like 512M, 1G, etc.
Using .htaccess increase the upload size limit
You can edit the .htaccess root file of your website and paste the following code into it. The Apache webserver supports this file. This feature is not available on the nginx server.
php_value upload_max_filesize 64M
php_value post_max_size 128M
php_value memory_limit 256M
php_value max_execution_time 300
php_value max_input_time 300
Paste the above values in the .htaccess file to increase the upload size limit. Change the values as per your needs.
In NGINX server block.
If the file size limit increased using php.ini or function.php method and your nginx server stopped the upload, you can add the following code in the nginx server block.
By default nginx file size limit is 1MB. You can increase this value by adding client_max_body_size in the nginx.conf file.
For all server blocks, you can add the code into http block of nginx.conf
http {
...
client_max_body_size 100M;
}
Increase limit for a set of app/web, change values in the server block.
server {
...
client_max_body_size 100M;
}
Increase limit for particular directory location.
location /uploads {
...
client_max_body_size 100M;
}
After changing the above setting, you can restart or reload the nginx to load the new configurations.
I hope you liked the above article; in case of any doubt, feel free to ask in the comment section below.