If you run a WordPress site, you may have encountered issues when trying to upload files that are larger than the default limits set by PHP. To fix this, you need to modify the PHP settings in your server to increase the file upload limit.

In this post, we’ll go through the necessary PHP settings that you need to adjust to increase the file upload limit for your WordPress site.

Adjust max_execution_time and memory_limit settings

The max_execution_time setting in PHP determines how long a script is allowed to run before it’s terminated. By default, this value is set to 30 seconds, which might not be enough for larger file uploads. To increase this value to 300 seconds, add the following line to your PHP config file:

max_execution_time = 300

The memory_limit setting determines how much memory a PHP script can allocate. To be safe, you should set this to 256 MB or more. To increase this value to 128 MB, add the following line to your PHP config file:

memory_limit = 128M

Increase the max_input_vars setting

The max_input_vars setting determines the number of input variables that PHP can accept. If you’re uploading multiple files at once, this value needs to be increased. We recommend setting this value to 4000. To do this, add the following line to your PHP config file:

max_input_vars = 4000

Adjust post_max_size and upload_max_filesize settings

The post_max_size setting determines the maximum size of post data that PHP can accept. This value must be larger than the upload_max_filesize setting. To upload large files, you need to increase both of these values. We recommend setting the post_max_size to 64 MB and upload_max_filesize to 32 MB. To do this, add the following lines to your PHP config file:

post_max_size = 64M
upload_max_filesize = 32M

Set or Update client_max_body_size nginx setting if you’re using Nginx

If you’re using the Nginx web server, you need to increase the client_max_body_size setting as well. This setting determines the maximum size of the client request body. To increase it to 32 MB, add the following line to your Nginx config file:

client_max_body_size 32M;

Full settings

; the maximum time in seconds a script is allowed to run before it is terminated by the parser
max_execution_time = 300

; the maximum amount of memory in bytes that a script is allowed to allocate.
; Suggested: 256 MB or greater
memory_limit = 128M

; How many input variables may be accepted
max_input_vars = 4000

; Sets max size of post data allowed. To upload large files, this value must be larger than upload_max_filesize. 
post_max_size = 64M

; The maximum size of an uploaded file. post_max_size must be larger than this value.
upload_max_filesize = 32M

With these settings adjusted, you should now be able to upload larger files to your WordPress site. Keep in mind that these values are just suggestions, and you can adjust them to suit your needs. However, increasing them too much can impact the performance of your server, so be sure to test and adjust accordingly.