diff options
author | Florian Pritz <bluewind@xinu.at> | 2015-02-03 00:23:12 +0100 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2015-02-03 00:23:12 +0100 |
commit | cb52a4cdc2daa45a61c728f5ec83603e6c6a71fa (patch) | |
tree | 0470c7a3d39c41f6b2b87af8fc8700ad849e14cf /application/service/files.php | |
parent | 33efe571e3e7ebd607e92345c2e94e7fd8ae27f0 (diff) |
Rework error handling in upload validator
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/service/files.php')
-rw-r--r-- | application/service/files.php | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/application/service/files.php b/application/service/files.php index 8d8b1d01a..c270500ef 100644 --- a/application/service/files.php +++ b/application/service/files.php @@ -89,6 +89,10 @@ class files { $CI =& get_instance(); $errors = array(); + if (empty($files)) { + throw new \exceptions\UserInputException("file/no-file", "No file was uploaded or unknown error occured."); + } + foreach ($files as $key => $file) { $error_message = ""; @@ -113,7 +117,6 @@ class files { } else { $error_message = "Unknown error code: ".$file['error'].". Please report a bug."; } - } $filesize = filesize($file['tmp_name']); @@ -127,9 +130,8 @@ class files { "formfield" => $file["formfield"], "message" => $error_message, ); + throw new \exceptions\FileUploadVerifyException("file/upload-verify", "Failed to verify uploaded file(s)", $errors); } } - - return $errors; } } |