改进验证类的image方法

This commit is contained in:
thinkphp
2016-10-21 17:51:19 +08:00
parent 35a12fac90
commit 294a49b8b1

View File

@@ -723,6 +723,7 @@ class Validate
if (!($file instanceof File)) { if (!($file instanceof File)) {
return false; return false;
} }
if ($rule) {
$rule = explode(',', $rule); $rule = explode(',', $rule);
list($width, $height, $type) = getimagesize($file->getRealPath()); list($width, $height, $type) = getimagesize($file->getRealPath());
if (isset($rule[2])) { if (isset($rule[2])) {
@@ -734,8 +735,12 @@ class Validate
return false; return false;
} }
} }
list($w, $h) = $rule; list($w, $h) = $rule;
return $w == $width && $h == $height; return $w == $width && $h == $height;
} else {
return in_array($this->getImageType($file->getRealPath()), [1, 2, 3, 6]);
}
} }
/** /**