I want to add an upload image field to register a form in CodeIgniter.
My register code in the 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('isFileID', TRUE)
// && $this->input->post('FileID', 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
&& count(explode('-',$this->input->post('default-date', TRUE)) > 1)
){
Also my code in the model file:
<?php
class user extends CI_Model {
public function add() {
$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')))
);
$this->db->insert('admins', $data);
}
public function edit($id = FALSE) {
$this->db->set('name', $this->input->post('name'));
$this->db->set('email', $this->input->post('email'));
$this->db->set('phone', $this->input->post('phone'));
$this->db->set('mobile', $this->input->post('mobile'));
$this->db->set('birth_date', $this->input->post('birth'));
$this->db->set('first_name', $this->input->post('first_name'));
$this->db->set('last_name', $this->input->post('last_name'));
$this->db->set('city', $this->input->post('city'));
$this->db->set('main_street', $this->input->post('main_street'));
$this->db->set('sub_street', $this->input->post('sub_street'));
if ($this->input->post('type')) {
$this->db->set('sex', $this->input->post('type'));
}
if ($this->input->post('lat') and $this->input->post('lng')) {
$this->db->set('location', serialize(array($this->input->post('lat'), $this->input->post('lng'))));
}
if ($this->input->post('password') !== '') {
$this->db->set('password', md5($this->input->post('password')));
}
$this->db->where('id', $id);
$this->db->update('admins');
}
public function del($id = FALSE) {
$this->db->where('id', $id);
$this->db->delete('admins');
}
}
I want to add a field that allows to upload images.