Handle empty files due to upload_max_filesize

This commit is contained in:
Andy Miller
2019-03-12 18:29:13 -06:00
parent 030e4ae073
commit 33ac06bc2c
3 changed files with 12 additions and 1 deletions

View File

@@ -7,6 +7,7 @@
* Improved image background overlay and tools
* Update all Form classes to rely on `PageInterface` instead of `Page` class
* Removed `media.upload_limit` references
* Improve error when upload exceeds `upload_max_filesize`
1. [](#bugfix)
* Incorrect 2FA lang code [#1618](https://github.com/getgrav/grav-plugin-admin/issues/1618)
* Fixed potential undefined property in `onPageNotFound` event handling

View File

@@ -1567,6 +1567,15 @@ class AdminController extends AdminBaseController
/** @var Config $config */
$config = $this->grav['config'];
if (!isset($_FILES) || empty($_FILES)) {
$this->admin->json_response = [
'status' => 'error',
'message' => $this->admin::translate('PLUGIN_ADMIN.EXCEEDED_POSTMAX_LIMIT')
];
return false;
}
if (!isset($_FILES['file']['error']) || is_array($_FILES['file']['error'])) {
$this->admin->json_response = [
'status' => 'error',

View File

@@ -178,7 +178,8 @@ PLUGIN_ADMIN:
NO_PAGE_FOUND: "No Page found"
INVALID_PARAMETERS: "Invalid Parameters"
NO_FILES_SENT: "No files sent"
EXCEEDED_FILESIZE_LIMIT: "Exceeded PHP configuration file size limit"
EXCEEDED_FILESIZE_LIMIT: "Exceeded PHP configuration upload_max_filesize"
EXCEEDED_POSTMAX_LIMIT: "Exceeded PHP configuration post_max_size"
UNKNOWN_ERRORS: "Unknown errors"
EXCEEDED_GRAV_FILESIZE_LIMIT: "Exceeded Grav configuration file size limit"
UNSUPPORTED_FILE_TYPE: "Unsupported file type"