From 991f7426e8ec2a566ad82043b22ce844a5a1cfa1 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sun, 12 Feb 2017 13:34:56 -0500 Subject: Improve error reporting when file upload is not configured properly --- app/Controller/TaskFileController.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'app/Controller/TaskFileController.php') diff --git a/app/Controller/TaskFileController.php b/app/Controller/TaskFileController.php index 8a0971e4..ff0c299e 100644 --- a/app/Controller/TaskFileController.php +++ b/app/Controller/TaskFileController.php @@ -52,12 +52,21 @@ class TaskFileController extends BaseController public function save() { $task = $this->getTask(); + $result = $this->taskFileModel->uploadFiles($task['id'], $this->request->getFileInfo('files')); - if (! $this->taskFileModel->uploadFiles($task['id'], $this->request->getFileInfo('files'))) { - $this->flash->failure(t('Unable to upload the file.')); - } + if ($this->request->isAjax()) { + if (! $result) { + $this->response->json(array('message' => t('Unable to upload files, check the permissions of your data folder.')), 500); + } else { + $this->response->json(array('message' => 'OK')); + } + } else { + if (! $result) { + $this->flash->failure(t('Unable to upload files, check the permissions of your data folder.')); + } - $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])), true); + $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])), true); + } } /** -- cgit v1.2.3