mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
改进验证类的image方法
This commit is contained in:
@@ -723,19 +723,24 @@ class Validate
|
||||
if (!($file instanceof File)) {
|
||||
return false;
|
||||
}
|
||||
$rule = explode(',', $rule);
|
||||
list($width, $height, $type) = getimagesize($file->getRealPath());
|
||||
if (isset($rule[2])) {
|
||||
$imageType = strtolower($rule[2]);
|
||||
if ('jpeg' == $imageType) {
|
||||
$imageType = 'jpg';
|
||||
}
|
||||
if (image_type_to_extension($type, false) != $imageType) {
|
||||
return false;
|
||||
if ($rule) {
|
||||
$rule = explode(',', $rule);
|
||||
list($width, $height, $type) = getimagesize($file->getRealPath());
|
||||
if (isset($rule[2])) {
|
||||
$imageType = strtolower($rule[2]);
|
||||
if ('jpeg' == $imageType) {
|
||||
$imageType = 'jpg';
|
||||
}
|
||||
if (image_type_to_extension($type, false) != $imageType) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
list($w, $h) = $rule;
|
||||
return $w == $width && $h == $height;
|
||||
} else {
|
||||
return in_array($this->getImageType($file->getRealPath()), [1, 2, 3, 6]);
|
||||
}
|
||||
list($w, $h) = $rule;
|
||||
return $w == $width && $h == $height;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user