diff --git a/modules/document_repository/jsx/uploadForm.js b/modules/document_repository/jsx/uploadForm.js index 7785e00d445..beb5b893ad3 100644 --- a/modules/document_repository/jsx/uploadForm.js +++ b/modules/document_repository/jsx/uploadForm.js @@ -240,6 +240,12 @@ class DocUploadForm extends Component { 'error' ); } + if (resp.status == 400) { + swal.fire('Something went wrong', + JSON.parse(resp.response).message, + 'error' + ); + } } }).catch((error) => { console.error(error); diff --git a/modules/document_repository/php/files.class.inc b/modules/document_repository/php/files.class.inc index 3eb5efc6a97..7dd50b224f1 100644 --- a/modules/document_repository/php/files.class.inc +++ b/modules/document_repository/php/files.class.inc @@ -316,20 +316,18 @@ class Files extends \NDB_Page if (!is_array($body)) { throw new \LorisException("Expected parsed body to be an array"); } - - $category = $body['category']; // required - if (!\Utility::valueIsPositiveInteger($category)) { - // $category is a string representation of an ID, and so should be - // at least equal to zero. - return new \LORIS\Http\Response\JSON\BadRequest(self::BAD_CATEGORY); - } - $uploadedFiles = $request->getUploadedFiles()['files'] ?? null; if (is_null($uploadedFiles)) { header("HTTP/1.1 413 Too_large"); exit; } + $category = $body['category']; // required + if (!\Utility::valueIsPositiveInteger(strval($category))) { + // $category is a string representation of an ID, and so should be + // at least equal to zero. + return new \LORIS\Http\Response\JSON\BadRequest(self::BAD_CATEGORY); + } $uploadedFiles = is_array($uploadedFiles) ? $uploadedFiles : [$uploadedFiles];