If you get one of the errors below during a request:
PostTooLargeException in ValidatePostSize.php line XX:
HTTP 500 Payload Too Large
Unable to decode input (e.g. during Image upload)
or any other error related to size, time or memory limit
You have to check the following parameters in your php.ini file:
max_file_size
upload_max_filesize
post_max_size
You will have this issue on several occasions and it's usually because the (default) max_file_size value is small than the size of the file you try to upload.
If you facing the issue above, as well as the file size limit, there is also a memory limit to consider. Several variables (from your php.ini file) need consideration…
post_max_size
upload_max_filesize
max_execution_time
max_input_time
memory_limitThis configuration can allow you to upload 17MB file
post_max_size = 128M
upload_max_filesize = 64M
max_execution_time = 120
max_input_time = 240
memory_limit = 512MDone.
If the solution above doesn't solve the issue (that is very rare), you need to consider the settings below:
Nginx Settings
Even without knowing how to configure it, you need to care about one setting in nginx.conf file: client_max_body_size. Here’s the official documentation.
As you can read, default value is only 1m, which means that your whole POST request may be maximum 1MB. So you need to change that setting to 20m or higher.
Apache Settings
If you’re using Apache web-server, there’s also a setting for that called LimitRequestBody. Here’s the official documentation. The difference here is that Apache doesn’t give any restrictions by default. So there’s a chance that you will never need to edit this value, but just in case, it’s good to know it exists.