I have a form that lets users upload files but I'm having problems detecting files that are too large.
I have the following set in php.ini:
upload_max_filesize = 10M
post_max_size = 20M
I understand that the standard way to detect if files are larger than the config file allows is to check $_FILES['file_name']['error']
. However this only works for me if the actual file is greater than upload_max_filesize
and smaller than post_max_size
.
If the actual file size is greater than post_max_size
then the $_FILES
variable is removed and I get the log message:
PHP Warning: POST Content-Length of xxx bytes exceeds the limit of yyy ...
So the question: How do I detect if a user is uploading a file that is greater than post_max_size
? I need to display a valid user message if this happens.
Thanks.