From e60466dabc6767aeaa6b2db7233cc64faec51017 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 28 Feb 2024 06:21:07 +0900 Subject: [PATCH] fix: ErrorException is thrown if getimagesize() returns false ErrorException Trying to access array offset on value of type bool --- system/Validation/FileRules.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/system/Validation/FileRules.php b/system/Validation/FileRules.php index ce0ed8140d..d09d660029 100644 --- a/system/Validation/FileRules.php +++ b/system/Validation/FileRules.php @@ -242,7 +242,13 @@ class FileRules $allowedHeight = $params[1] ?? 0; // Get uploaded image size - $info = getimagesize($file->getTempName()); + $info = getimagesize($file->getTempName()); + + if ($info === false) { + // Cannot get the image size. + return false; + } + $fileWidth = $info[0]; $fileHeight = $info[1];