I am working with image updating api in codeigniter,If i update my image then function is working fine but if i not uploading any image then image field become "Null" in database.Here is my code
$add_data['user_id'] = ($this->input->post('user_id') && !empty($this->input->post('user_id'))) ? $this->input->post('user_id') : NULL;
if(!file_exists($_FILES['resume']['tmp_name']) || !is_uploaded_file($_FILES['resume']['tmp_name']))
{
$add_data['resume'] = ($this->input->post('resume') && !empty($this->input->post('resume'))) ? $this->input->post('resume') : NULL;
$add_data['resume']=$add_data['resume'];
}
else
{
$filename=time().uniqid(rand()).$_FILES['resume']['name'];
move_uploaded_file($_FILES["resume"]["tmp_name"], "resume/" . $filename);
$add_data['resume']=$filename;
}
$data = array(
'resume'=>$add_data['resume'],
);
$this->db->where('id',$add_data['user_id']);
$query=$this->db->update('users_info', $data);