mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-07 05:45:53 +01:00
Fix PHP error happening when uploading file without extension if the JS dropzone uploader is configured to allow empty file extensions
This commit is contained in:
@@ -628,15 +628,18 @@ class AdminController
|
|||||||
|
|
||||||
// Check extension
|
// Check extension
|
||||||
$fileParts = pathinfo($_FILES['file']['name']);
|
$fileParts = pathinfo($_FILES['file']['name']);
|
||||||
$fileExt = strtolower($fileParts['extension']);
|
|
||||||
|
$fileExt = '';
|
||||||
|
if (isset($fileParts['extension'])) {
|
||||||
|
$fileExt = strtolower($fileParts['extension']);
|
||||||
|
}
|
||||||
|
|
||||||
// If not a supported type, return
|
// If not a supported type, return
|
||||||
if (!$config->get("media.{$fileExt}")) {
|
if (!$fileExt || !$config->get("media.{$fileExt}")) {
|
||||||
$this->admin->json_response = ['status' => 'error', 'message' => $this->admin->translate('PLUGIN_ADMIN.UNSUPPORTED_FILE_TYPE') . ': '.$fileExt];
|
$this->admin->json_response = ['status' => 'error', 'message' => $this->admin->translate('PLUGIN_ADMIN.UNSUPPORTED_FILE_TYPE') . ': '.$fileExt];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Upload it
|
// Upload it
|
||||||
if (!move_uploaded_file($_FILES['file']['tmp_name'], sprintf('%s/%s', $page->path(), $_FILES['file']['name']))) {
|
if (!move_uploaded_file($_FILES['file']['tmp_name'], sprintf('%s/%s', $page->path(), $_FILES['file']['name']))) {
|
||||||
$this->admin->json_response = ['status' => 'error', 'message' => $this->admin->translate('PLUGIN_ADMIN.FAILED_TO_MOVE_UPLOADED_FILE')];
|
$this->admin->json_response = ['status' => 'error', 'message' => $this->admin->translate('PLUGIN_ADMIN.FAILED_TO_MOVE_UPLOADED_FILE')];
|
||||||
|
|||||||
Reference in New Issue
Block a user