From 60a45dbb685eb3b810dcced4820afe9d1f1ffe2d Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Sun, 25 May 2014 15:15:59 -0400 Subject: Improve file upload --- app/Controller/File.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'app/Controller') diff --git a/app/Controller/File.php b/app/Controller/File.php index 1604ab13..38cb82ab 100644 --- a/app/Controller/File.php +++ b/app/Controller/File.php @@ -24,6 +24,7 @@ class File extends Base $this->response->html($this->taskLayout('file_new', array( 'task' => $task, 'menu' => 'tasks', + 'max_size' => ini_get('upload_max_filesize'), 'title' => t('Attach a document') ))); } @@ -36,8 +37,14 @@ class File extends Base public function save() { $task = $this->getTask(); - $this->file->upload($task['project_id'], $task['id'], 'files'); - $this->response->redirect('?controller=task&action=show&task_id='.$task['id'].'#attachments'); + + if ($this->file->upload($task['project_id'], $task['id'], 'files') === true) { + $this->response->redirect('?controller=task&action=show&task_id='.$task['id'].'#attachments'); + } + else { + $this->session->flashError(t('Unable to upload the file.')); + $this->response->redirect('?controller=file&action=create&task_id='.$task['id']); + } } /** -- cgit v1.2.3