Improve file upload
This commit is contained in:
parent
f9753e91d2
commit
60a45dbb68
|
|
@ -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']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -371,4 +371,6 @@ return array(
|
|||
// 'Unable to update your sub-task.' => '',
|
||||
// 'Unable to create your sub-task.' => '',
|
||||
// 'Sub-task added successfully.' => '',
|
||||
// 'Maximum size: ' => '',
|
||||
// 'Unable to upload the file.' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -369,4 +369,6 @@ return array(
|
|||
// 'Unable to update your sub-task.' => '',
|
||||
// 'Unable to create your sub-task.' => '',
|
||||
// 'Sub-task added successfully.' => '',
|
||||
// 'Maximum size: ' => '',
|
||||
// 'Unable to upload the file.' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -369,4 +369,6 @@ return array(
|
|||
'Unable to update your sub-task.' => 'Impossible de mettre à jour votre sous-tâche.',
|
||||
'Unable to create your sub-task.' => 'Impossible de créer votre sous-tâche.',
|
||||
'Sub-task added successfully.' => 'Sous-tâche ajouté avec succès.',
|
||||
'Maximum size: ' => 'Taille maximum : ',
|
||||
'Unable to upload the file.' => 'Impossible de transférer le fichier.',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -374,4 +374,6 @@ return array(
|
|||
// 'Unable to update your sub-task.' => '',
|
||||
// 'Unable to create your sub-task.' => '',
|
||||
// 'Sub-task added successfully.' => '',
|
||||
// 'Maximum size: ' => '',
|
||||
// 'Unable to upload the file.' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -370,4 +370,6 @@ return array(
|
|||
// 'Unable to update your sub-task.' => '',
|
||||
// 'Unable to create your sub-task.' => '',
|
||||
// 'Sub-task added successfully.' => '',
|
||||
// 'Maximum size: ' => '',
|
||||
// 'Unable to upload the file.' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ class File extends Base
|
|||
|
||||
if (@move_uploaded_file($uploaded_filename, self::BASE_PATH.$destination_filename)) {
|
||||
|
||||
$this->create(
|
||||
return $this->create(
|
||||
$task_id,
|
||||
$original_filename,
|
||||
$destination_filename,
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
<form action="?controller=file&action=save&task_id=<?= $task['id'] ?>" method="post" enctype="multipart/form-data">
|
||||
<input type="file" name="files[]" multiple />
|
||||
<div class="form-help"><?= t('Maximum size: ') ?><?= is_integer($max_size) ? Helper\format_bytes($max_size) : $max_size ?></div>
|
||||
<div class="form-actions">
|
||||
<input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"/>
|
||||
<?= t('or') ?>
|
||||
|
|
|
|||
Loading…
Reference in New Issue