改进File类checkImg方法

This commit is contained in:
thinkphp
2016-11-01 11:43:50 +08:00
parent 17d146d0d9
commit 4a609c7254

View File

@@ -230,11 +230,11 @@ class File extends SplFileObject
{ {
$extension = strtolower(pathinfo($this->getInfo('name'), PATHINFO_EXTENSION)); $extension = strtolower(pathinfo($this->getInfo('name'), PATHINFO_EXTENSION));
/* 对图像文件进行严格检测 */ /* 对图像文件进行严格检测 */
if (in_array($extension, ['gif', 'jpg', 'jpeg', 'bmp', 'png', 'swf']) && !in_array($this->getImageType($this->filename), [1, 2, 3, 4, 6])) { if (in_array($extension, ['gif', 'jpg', 'jpeg', 'bmp', 'png', 'swf']) && in_array($this->getImageType($this->filename), [1, 2, 3, 4, 6])) {
return false;
}
return true; return true;
} }
return false;
}
// 判断图像类型 // 判断图像类型
protected function getImageType($image) protected function getImageType($image)