В настоящее время вы используете SESSION
для отображения данных. поэтому вы должны сбросить все SESSION
после обновления данных. Проверьте этот код.
public function update($userId) {
$maxDim = 100;
$file_name = $_FILES['userImg']['tmp_name'];
list($width, $height, $type, $attr) = getimagesize( $file_name );
if ( $width > $maxDim || $height > $maxDim ) {
$target_filename = $file_name;
$ratio = $width/$height;
if( $ratio > 1) {
$new_width = $maxDim;
$new_height = $maxDim/$ratio;
} else {
$new_width = $maxDim*$ratio;
$new_height = $maxDim;
}
$src = imagecreatefromstring( file_get_contents( $file_name ) );
$dst = imagecreatetruecolor( $new_width, $new_height );
imagecopyresampled( $dst, $src, 0, 0, 0, 0, $new_width, $new_height, $width, $height );
imagedestroy( $src );
imagepng( $dst, $target_filename ); // adjust format as needed
imagedestroy( $dst );
}
if (isset($_FILES) && $_FILES['userImg']['error'] == '0') {
$config['upload_path'] = './upload/user';
$config["allowed_types"] = "*";
$config['max_size'] = 1024;
$config['max_width'] = 1000;
$config['max_height'] = 1000;
$config['overwrite'] = TRUE;
$new_name = $this->input->post("userUsername");
$config['file_name'] = $new_name;
$this->load->library('upload', $config);
$this->upload->initialize($config);
if ( ! $this->upload->do_upload('userImg'))
{
$error = array('error' => $this->upload->display_errors());
echo json_encode($error);
}
else{
$upload_data = $this->upload->data();
$data = array (
"userUsername" => $this->input->post("people_username"),
"userPass" => $this->input->post("people_pass"),
"userEmail" => $this->input->post("people_email"),
"userName" => $this->input->post("people_name"),
"userSurname" => strtoupper($this->input->post("people_surname")),
"userImg" => $upload_data['file_name'],
"userLang" => $this->input->post("people_lang"),
"userType" => $this->input->post("people_type"),
"userModifyDate" => date('Y-m-d H:i:s'),
);
$update = $this->db->where("userId", $userId)->update("user", $data);
if($update) {
$this->session->set_userdata('people_username',$this->input->post("people_username"));
$this->session->set_userdata('people_pass',$this->input->post("people_pass"));
$this->session->set_userdata('people_email',$this->input->post("people_email"));
$this->session->set_userdata('people_name',$this->input->post("people_name"));
$this->session->set_userdata('people_surname',$this->input->post("people_surname"));
$this->session->set_userdata('people_lang',$this->input->post("people_lang"));
$this->session->set_userdata('people_type',$this->input->post("people_type"));
redirect(base_url("profile"));
}else {
echo "Hata!";
}
}
}
else{
$data = array (
"userUsername" => $this->input->post("people_username"),
"userPass" => $this->input->post("people_pass"),
"userEmail" => $this->input->post("people_email"),
"userName" => $this->input->post("people_name"),
"userSurname" => strtoupper($this->input->post("people_surname")),
"userLang" => $this->input->post("people_lang"),
"userType" => $this->input->post("people_type"),
"userModifyDate" => date('Y-m-d H:i:s'),
);
$update = $this->db->where("userId", $userId)->update("user", $data);
if($update) {
$this->session->set_userdata('people_username',$this->input->post("people_username"));
$this->session->set_userdata('people_pass',$this->input->post("people_pass"));
$this->session->set_userdata('people_email',$this->input->post("people_email"));
$this->session->set_userdata('people_name',$this->input->post("people_name"));
$this->session->set_userdata('people_surname',$this->input->post("people_surname"));
$this->session->set_userdata('people_lang',$this->input->post("people_lang"));
$this->session->set_userdata('people_type',$this->input->post("people_type"));
redirect(base_url("profile"));
}else {
echo "Hata!";
}
}
}