Improve file upload
This commit is contained in:
@@ -24,6 +24,7 @@ class File extends Base
|
|||||||
$this->response->html($this->taskLayout('file_new', array(
|
$this->response->html($this->taskLayout('file_new', array(
|
||||||
'task' => $task,
|
'task' => $task,
|
||||||
'menu' => 'tasks',
|
'menu' => 'tasks',
|
||||||
|
'max_size' => ini_get('upload_max_filesize'),
|
||||||
'title' => t('Attach a document')
|
'title' => t('Attach a document')
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
@@ -36,8 +37,14 @@ class File extends Base
|
|||||||
public function save()
|
public function save()
|
||||||
{
|
{
|
||||||
$task = $this->getTask();
|
$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 update your sub-task.' => '',
|
||||||
// 'Unable to create your sub-task.' => '',
|
// 'Unable to create your sub-task.' => '',
|
||||||
// 'Sub-task added successfully.' => '',
|
// '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 update your sub-task.' => '',
|
||||||
// 'Unable to create your sub-task.' => '',
|
// 'Unable to create your sub-task.' => '',
|
||||||
// 'Sub-task added successfully.' => '',
|
// '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 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.',
|
'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.',
|
'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 update your sub-task.' => '',
|
||||||
// 'Unable to create your sub-task.' => '',
|
// 'Unable to create your sub-task.' => '',
|
||||||
// 'Sub-task added successfully.' => '',
|
// '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 update your sub-task.' => '',
|
||||||
// 'Unable to create your sub-task.' => '',
|
// 'Unable to create your sub-task.' => '',
|
||||||
// 'Sub-task added successfully.' => '',
|
// '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)) {
|
if (@move_uploaded_file($uploaded_filename, self::BASE_PATH.$destination_filename)) {
|
||||||
|
|
||||||
$this->create(
|
return $this->create(
|
||||||
$task_id,
|
$task_id,
|
||||||
$original_filename,
|
$original_filename,
|
||||||
$destination_filename,
|
$destination_filename,
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
<form action="?controller=file&action=save&task_id=<?= $task['id'] ?>" method="post" enctype="multipart/form-data">
|
<form action="?controller=file&action=save&task_id=<?= $task['id'] ?>" method="post" enctype="multipart/form-data">
|
||||||
<input type="file" name="files[]" multiple />
|
<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">
|
<div class="form-actions">
|
||||||
<input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"/>
|
<input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"/>
|
||||||
<?= t('or') ?>
|
<?= t('or') ?>
|
||||||
|
|||||||
Reference in New Issue
Block a user