diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2021-04-08 16:12:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-08 16:12:36 +0200 |
commit | b43e21d18606d6ae8297438729487458401ad098 (patch) | |
tree | ef72e7826685dcee2e63ee83f0303ccce50534c6 /core/Controller | |
parent | 2bedbc1793d65be0b688c5131a43c74a9f483012 (diff) | |
parent | 7b6989747463773dcd4d3bba3854b8e713a1d214 (diff) | |
download | nextcloud-server-b43e21d18606d6ae8297438729487458401ad098.tar.gz nextcloud-server-b43e21d18606d6ae8297438729487458401ad098.zip |
Merge pull request #26401 from nextcloud/enh/handle-avatar-upload-errors
Show informative errors on avatar upload error
Diffstat (limited to 'core/Controller')
-rw-r--r-- | core/Controller/AvatarController.php | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/core/Controller/AvatarController.php b/core/Controller/AvatarController.php index 69ec2f4bffe..34815321495 100644 --- a/core/Controller/AvatarController.php +++ b/core/Controller/AvatarController.php @@ -193,8 +193,20 @@ class AvatarController extends Controller { $content = $this->cache->get('avatar_upload'); unlink($files['tmp_name'][0]); } else { + $phpFileUploadErrors = [ + UPLOAD_ERR_OK => $this->l->t('The file was uploaded'), + UPLOAD_ERR_INI_SIZE => $this->l->t('The uploaded file exceeds the upload_max_filesize directive in php.ini'), + UPLOAD_ERR_FORM_SIZE => $this->l->t('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form'), + UPLOAD_ERR_PARTIAL => $this->l->t('The file was only partially uploaded'), + UPLOAD_ERR_NO_FILE => $this->l->t('No file was uploaded'), + UPLOAD_ERR_NO_TMP_DIR => $this->l->t('Missing a temporary folder'), + UPLOAD_ERR_CANT_WRITE => $this->l->t('Could not write file to disk'), + UPLOAD_ERR_EXTENSION => $this->l->t('A PHP extension stopped the file upload'), + ]; + $message = $phpFileUploadErrors[$files['error'][0]] ?? $this->l->t('Invalid file provided'); + $this->logger->warning($message, ['app' => 'core']); return new JSONResponse( - ['data' => ['message' => $this->l->t('Invalid file provided')]], + ['data' => ['message' => $message]], Http::STATUS_BAD_REQUEST ); } |