Show a more meaningful error message if post_max_size is too low to handle a media upload

This commit is contained in:
Flavio Copes
2016-03-19 11:54:19 +01:00
parent f612900220
commit 1044ffebf1
2 changed files with 19 additions and 2 deletions

View File

@@ -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',