Improve file upload

This commit is contained in:
Frédéric Guillot
2014-05-25 15:15:59 -04:00
parent f9753e91d2
commit 60a45dbb68
8 changed files with 21 additions and 3 deletions

View File

@@ -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']);
}
}
/**