The PHP manual has a section called Handling file uploads. That section has a subsection called Error Messages Explained. That subsection describes an error called "UPLOAD_ERR_INI_SIZE":
Value: 1; The uploaded file exceeds the upload_max_filesize directive in php.ini.
However, in my experience, it's impossible to ever check for this particular error using UPLOAD_ERR_INI_SIZE because if a user ever does upload a file that exceeds the upload_max_filesize directive in php.ini, the $_FILES superglobal is empty. Want to test it for yourself? Save this as "upload_test.php" and then try to upload a file that's under the limit and then a file that's over the limit:
<?php
if (isset($_GET['submitted']) && $_GET['submitted'] === 'true')
{
echo 'Contents of $_POST:<hr><pre>';
print_r($_POST);
echo '</pre><hr>Contents of $_FILES:<hr><pre>';
print_r($_FILES);
echo '</pre><hr>';
exit;
}
$max_filesize_in_mib = min((int)(ini_get('upload_max_filesize')), (int)(ini_get('post_max_size')), (int)(ini_get('memory_limit')));
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>PHP Upload Test</title>
</head>
<body>
<h1>Upload a File (Maximum File Size: <?php echo $max_filesize_in_mib; ?> MiB)</h1>
<form action="upload_test.php?submitted=true" enctype="multipart/form-data" method="post">
<input type="file" name="upload_test">
<input type="hidden" name="random_field" value="You should see this field in the $_POST superglobal.">
<input type="submit" value="Upload">
</form>
</body>
</html>
So my question is this: what's the point of UPLOAD_ERR_INI_SIZE if you can never check for it?