How to display an error when the uploaded files are exceeding post_max_size
php?
print_r($_FILES);
I get an empty array when I have exceeded the post_max_size
array()
I got this from php.net but I don't understand it and don't know how to do it,
If the size of post data is greater than post_max_size, the $_POST and $_FILES superglobals are empty. This can be tracked in various ways, e.g. by passing the $_GET variable to the script processing the data, i.e. , and then checking if $_GET['processed'] is set.
This is my form,
<form action="upload.php" method="post" enctype="multipart/form-data">
<input type="file" multiple="multiple" name="file[]" />
<input type="submit" name="upload" value="Submit"/>
</form>
If
$_SERVER['CONTENT_LENGTH']
is non zero and$_POST
and$_FILES
are empty, then the upload was too big.You can write a simple size validation, to avoid that...
Something like...
I have slightly modified toopay's code and I think you are looking for this. ini_get('post_max_size') helps you get the max size allowed.