From 08135ee843066fd4b542800ff652e2e491cb441b Mon Sep 17 00:00:00 2001 From: Flavio Copes Date: Sat, 16 Jan 2016 18:49:42 +0100 Subject: [PATCH] Fix PHP error happening when uploading file without extension if the JS dropzone uploader is configured to allow empty file extensions --- classes/controller.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/classes/controller.php b/classes/controller.php index a67100cf..1d771139 100644 --- a/classes/controller.php +++ b/classes/controller.php @@ -628,15 +628,18 @@ class AdminController // Check extension $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 (!$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]; return; } - // Upload it 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')];