From fd426b4d492dcef4a4ea205d2bbcf0a596e4f0ab Mon Sep 17 00:00:00 2001 From: Flavio Copes Date: Mon, 10 Oct 2016 13:07:34 +0200 Subject: [PATCH] Show more helpful error message if destination is not specified in a `file` field --- classes/controller.php | 9 +++++++++ languages/en.yaml | 1 + 2 files changed, 10 insertions(+) diff --git a/classes/controller.php b/classes/controller.php index a1b3e4c8..518198c1 100644 --- a/classes/controller.php +++ b/classes/controller.php @@ -1652,6 +1652,15 @@ class AdminController $upload = $this->normalizeFiles($_FILES['data'], $settings->name); + if (!isset($settings->destination)) { + $this->admin->json_response = [ + 'status' => 'error', + 'message' => $this->admin->translate('PLUGIN_ADMIN.DESTINATION_NOT_SPECIFIED', null, true) + ]; + + return false; + } + // Do not use self@ outside of pages if ($this->view != 'pages' && in_array($settings->destination, ['@self', 'self@'])) { $this->admin->json_response = [ diff --git a/languages/en.yaml b/languages/en.yaml index 794d1166..004cf437 100644 --- a/languages/en.yaml +++ b/languages/en.yaml @@ -612,4 +612,5 @@ PLUGIN_ADMIN: DROPZONE_RESPONSE_ERROR: "Server responded with {{statusCode}} code." ADMIN_CACHING: "Enable Admin Caching" ADMIN_CACHING_HELP: "Caching in the admin can be controlled independently from the front-end site" + DESTINATION_NOT_SPECIFIED: "Destination not specified" UPLOAD_ERR_NO_TMP_DIR: "Missing a temporary folder"