diff --git a/system/Validation/FileRules.php b/system/Validation/FileRules.php index 5d510008a893..13c79ecab50f 100644 --- a/system/Validation/FileRules.php +++ b/system/Validation/FileRules.php @@ -133,6 +133,11 @@ public function max_size(string $blank = null, string $params, array $data): boo return false; } + if ($file->getError() === UPLOAD_ERR_NO_FILE) + { + return true; + } + if ($file->getSize() / 1024 > $params[0]) { return false; @@ -173,6 +178,11 @@ public function is_image(string $blank = null, string $params, array $data): boo return false; } + if ($file->getError() === UPLOAD_ERR_NO_FILE) + { + return true; + } + // We know that our mimes list always has the first mime // start with `image` even when then are multiple accepted types. $type = \Config\Mimes::guessTypeFromExtension($file->getExtension()); @@ -216,6 +226,11 @@ public function mime_in(string $blank = null, string $params, array $data): bool return false; } + if ($file->getError() === UPLOAD_ERR_NO_FILE) + { + return true; + } + if (! in_array($file->getMimeType(), $params)) { return false; @@ -255,6 +270,11 @@ public function ext_in(string $blank = null, string $params, array $data): bool return false; } + if ($file->getError() === UPLOAD_ERR_NO_FILE) + { + return true; + } + if (! in_array($file->getExtension(), $params)) { return false; @@ -295,6 +315,11 @@ public function max_dims(string $blank = null, string $params, array $data): boo return false; } + if ($file->getError() === UPLOAD_ERR_NO_FILE) + { + return true; + } + // Get Parameter sizes $allowedWidth = $params[0] ?? 0; $allowedHeight = $params[1] ?? 0;