Multiple files upload in Codeigniter - Tamil Programmers
#behindthecode
The file can be easily uploaded to the server using PHP. Also, you can upload multiple files using PHP. For CodeIgniter web application.
The file can be easily uploaded to the server using PHP. Also, you can upload multiple files using PHP. For CodeIgniter web application.
1)form.php <!-- VIEW -->
<form method="post" action="<?=base_url('form/upload');?>" enctype="multipart/form-data">
<label class="form-label">Employee Other Documents </label>
<input type="file" name="document[]" multiple='true' class="form-control" >
<button class="btn btn-success waves-effect" type="submit">SUBMIT</button>
</form>
2)form.php //CONTROLLER
funtion upload()
{
$name = 'document'; //(input type="file") name
#MULTIPLE UPLOAD IMAGE
$filesCount = count($_FILES[$name]['name']);
for($i = 0; $i < $filesCount; $i++)
{
$_FILES['userFile']['name'] = $_FILES[$name]['name'][$i];
$_FILES['userFile']['type'] = $_FILES[$name]['type'][$i];
$_FILES['userFile']['tmp_name'] = $_FILES[$name]['tmp_name'][$i];
$_FILES['userFile']['error'] = $_FILES[$name]['error'][$i];
$_FILES['userFile']['size'] = $_FILES[$name]['size'][$i];
$uploadPath = './uploads/document/';
$config['upload_path'] = $uploadPath;
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$config['encrypt_name'] = TRUE;
$this->load->library('upload', $config);
if($this->upload->do_upload('userFile')){
$fileData = $this->upload->data();
$uploadData[$name][$i]['file_name'] = $fileData['file_name'];
}
else
{
echo "erR";
}
}
}
by
Tamil Programmers
Cool
பதிலளிநீக்கு