我的图片上传器设置了一条错误消息,以在上传的图片大于特定大小时显示。但是,如果我上传了非常大的内容,错误消息会被绕过,并且用户会看到我不希望他们看到的 POST Content-Length exceeded 错误消息。有人可以帮我弄清楚为什么太大的图像文件没有显示错误消息吗?
这是上传照片时调用的验证函数:
//------------------------------
private function _verify($fn) {
//------------------------------
global $_WEBCONFIG;
$isValid = TRUE;
$userID = isset($_POST["hidId"]) ? (int)$_POST["hidId"] : 0;
$this->record2->p_id = $this->proId;
$fieldName = "txtName";
$fieldValue = SanitizeData($_POST[$fieldName]);
if (!$fieldValue || strlen($fieldValue = trim($fieldValue)) == 0) {
$this->record2->i_name = '';
} else {
$this->record2->i_name = $fieldValue;
}
$fieldName = "fleImage";
if (isset($_FILES[$fieldName]) && strlen($_FILES[$fieldName]['name']) > 0) {
$fieldValue = $_FILES[$fieldName]['name'];
$file_ext = strtolower(GetExtName($fieldValue));
$arExts = explode(",", VALID_IMGS);
if (!in_array($file_ext, $arExts)) {
$this->errors[] = "Invalid Image Format. (Allowed image types: " . VALID_IMGS . ")";
$isValid = FALSE;
} else {
$size = getimagesize($_FILES[$fieldName]['tmp_name']);
if ($size[0] < $_WEBCONFIG['THUMB_WIDTH'] || $size[1] < $_WEBCONFIG['THUMB_HEIGHT']) {
$this->errors[] = "Invalid Image Size. (Image Dimensions: " . $_WEBCONFIG['IMAGE_WIDTH'] . " x " . $_WEBCONFIG['IMAGE_HEIGHT'] . " or larger)";
$isValid = FALSE;
}
$imageSize = filesize($_FILES[$fieldName]['tmp_name']);
if ($imageSize > 16777216){
$this->errors[] = "Invalid File Size. File size must be smaller than 128 MB.";
$isValid = FALSE;
}
}
} else if ($fn == 0) {
$this->errors[] = "Please upload an Image (Image Dimensions: " . $_WEBCONFIG['IMAGE_WIDTH'] . " x " . $_WEBCONFIG['IMAGE_HEIGHT'] . " or larger.)";
$isValid = FALSE;
}
$fieldName = "txtOrder";
$fieldValue = SanitizeData($_POST[$fieldName]);
if (strlen($fieldValue = trim($fieldValue)) == 0) {
$this->record2->i_sort_id = 99999;
} else {
$this->record2->i_sort_id = $fieldValue;
}
return $isValid;
}//end function
我上传的绕过错误消息的图像大小是 37.4 MB