Home >Backend Development >PHP Tutorial >Why am I getting the \'Maximum file size exceeded\' error when my upload_max_filesize is larger than post_max_size?
PHP: post_max_size Overriding upload_max_filesize
The PHP configuration parameters post_max_size and upload_max_filesize play crucial roles in determining the maximum allowable size for file uploads. However, confusing scenarios can arise when these values seemingly contradict each other.
As reported by Simon, his host showed the following settings:
Based on this information, it would be logical to assume the ability to upload files up to 16Mb. However, when attempting to upload a large file via the POST method, Simon encountered the error "Maximum file size exceeded."
To resolve this issue, it's important to understand the distinct roles of these parameters:
In Simon's case, while upload_max_filesize permits individual file sizes of up to 16Mb, the post_max_size restriction of 8Mb became the limiting factor for the entire request body.
To allow the upload of a 16Mb file, it's necessary to increase the value of post_max_size to a value greater than or equal to that of upload_max_filesize. This ensures that the total size of the POST request, including the uploaded file, remains within the permissible limit.
Regarding the question of alternative methods for uploading files larger than post_max_size, it's important to note that:
The above is the detailed content of Why am I getting the 'Maximum file size exceeded' error when my upload_max_filesize is larger than post_max_size?. For more information, please follow other related articles on the PHP Chinese website!