diff --git a/modules/document_repository/jsx/uploadForm.js b/modules/document_repository/jsx/uploadForm.js index 05241200a65..2adb8f10df5 100644 --- a/modules/document_repository/jsx/uploadForm.js +++ b/modules/document_repository/jsx/uploadForm.js @@ -222,17 +222,15 @@ class DocUploadForm extends Component { ); }); } else { - resp.json().then((data) => { - console.error(resp); - swal.fire('Could not upload files', data.error, 'error'); - }).catch((error) => { - console.error(error); - swal.fire( - 'Error reading error response', - 'Please report the issue or contact your administrator', - 'error' - ); - }); + if (resp.status == 413) { + swal.fire('File too large', 'Could not upload file', 'error'); + } + if (resp.status == 403) { + swal.fire('Permission denied', + 'Could not upload file', + '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 726cd2c996b..3eb5efc6a97 100644 --- a/modules/document_repository/php/files.class.inc +++ b/modules/document_repository/php/files.class.inc @@ -307,9 +307,8 @@ class Files extends \NDB_Page $name = $user->getUsername(); if (! $user->hasPermission('document_repository_edit')) { - return new \LORIS\Http\Response\JSON\Forbidden( - self::FORBIDDEN - ); + header("HTTP/1.1 403 Forbidden"); + exit; } // Do some validation and fail early on bad inputs. @@ -328,9 +327,8 @@ class Files extends \NDB_Page $uploadedFiles = $request->getUploadedFiles()['files'] ?? null; if (is_null($uploadedFiles)) { - return new \LORIS\Http\Response\JSON\BadRequest( - 'No files uploaded' - ); + header("HTTP/1.1 413 Too_large"); + exit; } $uploadedFiles = is_array($uploadedFiles)