$result = $this->db->insert('user_reg', $user_data);
if($result)
{
$userid = $this->db->insert_id();
$this->db->where('user_id', $userid);
$user_data = $this->db->get('user_reg')->row();
// $userid = $this->db->insert_id();
chmod('./upload/', 0777);
$path = './upload/'.$userid;
$binary=base64_decode($user_profile_img);
header('Content-Type: bitmap; charset=utf-8');
$img_path=$path.'/profile_image.jpg';
$file = fopen($img_path, 'wb');
fwrite($file, $binary);
$Gimage = mysql_real_escape_string(base_url($path.'/profile_image.jpg'));
fclose($file);
i am getting error saying fclose is using binary can anyone tell what is the solution and i am not able to understand with ci update function.i need to update image path in the table without changing other contents.