if(isset($_POST['uploadpic']))
{
$userid = trim($this->input->post('userid'));
$image = basename($_FILES["file"]["name"]);
$wherei = array(
'id' => $userid
);
$target_path = base_url('assets/userimages/');
$target_path = $target_path . basename($_FILES['file']['name']);
if(move_uploaded_file($_FILES['file']['tmp_name'], $target_path)) {
$updatedata = array( 'image' => $image );
$update = $this->user_model->UPDATEDATA('user',$wherei, $updatedata);
if($update){
$this->session->set_flashdata("success","Update Successfully.");
redirect('user/profile');
}else{
$this->session->set_flashdata("failed","Update Failed.");
redirect('user/profile');
}
} else {
$this->session->set_flashdata("failed", "Please Try Again" );
redirect("user/profile");
}
// echo $userid.'-'.$image;
// if ( ! $this->upload->do_upload('userfile'))
// {
// $error = array('error' => $this->upload->display_errors());
// $this->session->set_flashdata("error", $error );
// redirect("user/profile");
// }
// else
// {
// // $data = array('upload_data' => $this->upload->data());
// $updatedata = array('image' => $image );
// $update = $this->user_model->UPDATEDATA('user',$wherei, $updatedata);
// if($update){
// $this->session->set_flashdata("success","Update Successfully.");
// redirect('user/profile');
// }else{
// $this->session->set_flashdata("failed","Update Failed.");
// redirect('user/profile');
// }
// }
}
{
$userid = trim($this->input->post('userid'));
$image = basename($_FILES["file"]["name"]);
$wherei = array(
'id' => $userid
);
$target_path = base_url('assets/userimages/');
$target_path = $target_path . basename($_FILES['file']['name']);
if(move_uploaded_file($_FILES['file']['tmp_name'], $target_path)) {
$updatedata = array( 'image' => $image );
$update = $this->user_model->UPDATEDATA('user',$wherei, $updatedata);
if($update){
$this->session->set_flashdata("success","Update Successfully.");
redirect('user/profile');
}else{
$this->session->set_flashdata("failed","Update Failed.");
redirect('user/profile');
}
} else {
$this->session->set_flashdata("failed", "Please Try Again" );
redirect("user/profile");
}
// echo $userid.'-'.$image;
// if ( ! $this->upload->do_upload('userfile'))
// {
// $error = array('error' => $this->upload->display_errors());
// $this->session->set_flashdata("error", $error );
// redirect("user/profile");
// }
// else
// {
// // $data = array('upload_data' => $this->upload->data());
// $updatedata = array('image' => $image );
// $update = $this->user_model->UPDATEDATA('user',$wherei, $updatedata);
// if($update){
// $this->session->set_flashdata("success","Update Successfully.");
// redirect('user/profile');
// }else{
// $this->session->set_flashdata("failed","Update Failed.");
// redirect('user/profile');
// }
// }
}
Comments
Post a Comment