The method do_upload()
declared as public function do_upload($field = 'userfile')
,
so you can use it in your code like:
private function uploads() {
$config['upload_path'] = './images/imagegallaryslider';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '1000';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
//<--HERE the several images handler
foreach (array('userfile','img1','img2' as $field) {
if ( ! $this->upload->do_upload($field))
{
$error = array('error' => $this->upload->display_errors());
if($_FILES[$field]['name']=='')
{
$data['upload_error']='<strong>Error: Please, select image to upload</strong>';
}
else
{
$data['upload_error']='<strong>Error:Invalid file format or size</strong>';
}
return $data;
}
$data = array('upload_data' => $this->upload->data());
$filename= $this->upload->data();
$file_name=$this->upload->file_name;
$this->create_thumb($file_name);
// save data
$this->ip_date = $this->admin_model->get_date_ip();
$value_array = array('Name' => $this->input->post('name'),
'Image'=>$this->upload->file_name,
'CreatedBy' => $this->session->userdata('adminid'),
'CreatedDate'=>$this->ip_date->cur_date,
'CreatedIp'=>$this->ip_date->ip);
$id = $this->admin_model->save('imggallaryslider',$value_array);
}
$this->session->set_flashdata('notification',$this->lang->line('gen_succ_added'));
redirect(site_url('manage/img_gallaryslider/index'));
die();
}
in view it should look like:
<p>
<label>Image 1</label>
<input type="file" name="userfile" value=""/>
<input type="file" name="img1" value=""/>
<input type="file" name="img2" value=""/>
</p>