summaryrefslogtreecommitdiff
path: root/app/Controller/File.php
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-05-25 15:15:59 -0400
committerFrédéric Guillot <fred@kanboard.net>2014-05-25 15:15:59 -0400
commit60a45dbb685eb3b810dcced4820afe9d1f1ffe2d (patch)
tree0e098f3730730b017907eaa55494543244e027fe /app/Controller/File.php
parentf9753e91d288c4d87d6a83ffe994d312eae5a3fd (diff)
Improve file upload
Diffstat (limited to 'app/Controller/File.php')
-rw-r--r--app/Controller/File.php11
1 files changed, 9 insertions, 2 deletions
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']);
+ }
}
/**