diff --git a/library/think/File.php b/library/think/File.php index 4bcf5165..dc597701 100644 --- a/library/think/File.php +++ b/library/think/File.php @@ -242,8 +242,12 @@ class File extends SplFileObject if (function_exists('exif_imagetype')) { return exif_imagetype($image); } else { - $info = getimagesize($image); - return $info[2]; + try { + $info = getimagesize($image); + return $info ? $info[2] : false; + } catch (\Exception $e) { + return false; + } } } diff --git a/library/think/Validate.php b/library/think/Validate.php index 72b9307b..c12ee6d1 100644 --- a/library/think/Validate.php +++ b/library/think/Validate.php @@ -633,8 +633,12 @@ class Validate if (function_exists('exif_imagetype')) { return exif_imagetype($image); } else { - $info = getimagesize($image); - return $info[2]; + try { + $info = getimagesize($image); + return $info ? $info[2] : false; + } catch (\Exception $e) { + return false; + } } }