mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-05 04:46:03 +01:00
Show a more meaningful error message if post_max_size is too low to handle a media upload
This commit is contained in:
@@ -107,7 +107,23 @@ class AdminController
|
||||
} else {
|
||||
$nonce = $this->grav['uri']->param('admin-nonce');
|
||||
}
|
||||
if (!$nonce || !Utils::verifyNonce($nonce, 'admin-form')) {
|
||||
|
||||
if (!$nonce || !Utils::verifyNonce($nonce, 'admin-form'))
|
||||
{
|
||||
if ($this->task == 'addmedia') {
|
||||
|
||||
$message = sprintf($this->admin->translate('PLUGIN_ADMIN.FILE_TOO_LARGE', null, true), ini_get('post_max_size'));
|
||||
|
||||
//In this case it's more likely that the image is too big than POST can handle. Show message
|
||||
$this->admin->setMessage($message, 'error');
|
||||
$this->admin->json_response = [
|
||||
'status' => 'error',
|
||||
'message' => $message
|
||||
];
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.INVALID_SECURITY_TOKEN'), 'error');
|
||||
$this->admin->json_response = [
|
||||
'status' => 'error',
|
||||
|
||||
@@ -484,3 +484,4 @@ PLUGIN_ADMIN:
|
||||
FILE_ERROR_UPLOAD: "An error occurred while trying to upload the file"
|
||||
FILE_UNSUPPORTED: "Unsupported file type"
|
||||
ADD_ITEM: "Add item"
|
||||
FILE_TOO_LARGE: "The file is too large to be uploaded, maximum allowed is %s according <br>to your PHP settings. Increase your `post_max_size` PHP setting"
|
||||
Reference in New Issue
Block a user