From 5a74ffca25dfed87f02d90a4f5e0e60181ebb9c6 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 12 Sep 2017 14:55:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E6=96=87=E4=BB=B6=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E7=9A=84=E9=9D=9E=E6=B3=95=E5=9B=BE=E5=83=8F=E5=BC=82?= =?UTF-8?q?=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/File.php | 8 ++++++-- library/think/Validate.php | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) 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; + } } }