UploadErrorCode/UploadError use PHP UPLOAD_ERR_* numbers

This commit is contained in:
the-djmaze 2022-01-11 13:05:17 +01:00
parent b5201883d6
commit 6aedba9d36
6 changed files with 38 additions and 49 deletions

View file

@ -48,10 +48,10 @@ export const Scope = {
export const UploadErrorCode = {
Normal: 0,
FileIsTooBig: 1,
FilePartiallyUploaded: 2,
NoFileUploaded: 3,
MissingTempFolder: 4,
OnSavingFile: 5,
FilePartiallyUploaded: 3,
NoFileUploaded: 4,
MissingTempFolder: 6,
OnSavingFile: 7,
FileType: 98,
Unknown: 99
};

View file

@ -114,19 +114,8 @@ export const
* @returns {string}
*/
getUploadErrorDescByCode = code => {
let result = 'UNKNOWN';
code = parseInt(code, 10) || 0;
switch (code) {
case UploadErrorCode.FileIsTooBig:
case UploadErrorCode.FilePartiallyUploaded:
case UploadErrorCode.NoFileUploaded:
case UploadErrorCode.MissingTempFolder:
case UploadErrorCode.OnSavingFile:
case UploadErrorCode.FileType:
result = i18nKey(getKeyByValue(UploadErrorCode, code));
break;
}
return i18n('UPLOAD/ERROR_' + result);
let key = getKeyByValue(UploadErrorCode, parseInt(code, 10));
return i18n('UPLOAD/ERROR_' + (key ? i18nKey(key) : 'UNKNOWN'));
},
/**