I assume that you want to add the option "upload image" in the form
public function add() {
$config['upload_path'] = '/file_path/';
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$this->load->library('upload', $config);
$this->upload->do_upload('image');
$data_upload_files = $this->upload->data();
$image = $data_upload_files[full_path];
$data = array(
'name' => $this->input->post('name'),
'password' => $this->input->post('password'),
'add_date' => time(),
'email' => $this->input->post('email'),
'birth_date' => $this->input->post('birth'),
'phone' => $this->input->post('phone'),
'mobile' => $this->input->post('mobile'),
'sex' => $this->input->post('type'),
'city' => $this->input->post('city'),
'first_name' => $this->input->post('first_name'),
'last_name' => $this->input->post('last_name'),
'main_street' => $this->input->post('main_street'),
'sub_street' => $this->input->post('sub_street'),
'type' => $this->input->post('member_type'),
'delegate_name' => $this->input->post('delegate_name'),
'delegate_email' => $this->input->post('delegate_email'),
'delegate_pass' => md5($this->input->post('delegate_pass')),
'location' => serialize(array($this->input->post('lat'), $this->input->post('lng')))
'image'=>$image;
);
$this->db->insert('admins', $data);
}
There is something like this in the view
<input type="file" name="image" size="20" />
controller
function add_new_ticket() {
if ($this->input->post('fullname', TRUE)
&& $this->input->post('nID', TRUE)
&& $this->input->post('age', TRUE)
&& $this->input->post('gender', TRUE)
&& $this->input->post('phone', TRUE)
&& $this->input->post('type', TRUE)
&& $this->input->post('opsType', TRUE)
&& $this->input->post('clienc', TRUE)
&& $this->input->post('dr', TRUE)
&& strlen($this->input->post('phone', TRUE)) >= 9
&& strlen($this->input->post('nID', TRUE)) >= 9
&& (int) $this->input->post('age', TRUE) <= 99
&& $this->upload->do_upload()
&& count(explode('-',$this->input->post('default-date', TRUE)) > 1)
){
Note:
The login name must be defined as the same in $ this-> upload-> do_upload ('image'); i.e. name = "image"
The input element must have multiple = "multiple" or just multiple
3. $this- > load- > ( '');//
4. , $this- > upload- > do_upload() , , .
5. $this- > upload- > data() , , , , ..