mirror of
https://github.com/flarum/core.git
synced 2025-10-18 18:26:07 +02:00
Add extra error handling for avatar file size & large payload (#3042)
* Add extra error handling for avatar file size & large payload * Change error message to return 'upload failure' on most errors instead of 'no file' message
This commit is contained in:
committed by
GitHub
parent
1aa61f1f01
commit
eb0dd1f0d0
@@ -30,8 +30,18 @@ class AvatarValidator extends AbstractValidator
|
||||
|
||||
protected function assertFileRequired(UploadedFileInterface $file)
|
||||
{
|
||||
if ($file->getError() !== UPLOAD_ERR_OK) {
|
||||
$this->raise('required');
|
||||
$error = $file->getError();
|
||||
|
||||
if ($error !== UPLOAD_ERR_OK) {
|
||||
if ($error === UPLOAD_ERR_INI_SIZE || $error === UPLOAD_ERR_FORM_SIZE) {
|
||||
$this->raise('file_too_large');
|
||||
}
|
||||
|
||||
if ($error === UPLOAD_ERR_NO_FILE) {
|
||||
$this->raise('required');
|
||||
}
|
||||
|
||||
$this->raise('file_upload_failed');
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user