我正在尝试识别代码中的错误,我怀疑这是来自Controller的错误。
消息:未定义的变量:val
public function profile_updated()
{
$user_id = $this->session->userdata('user_id');
$profile_data = $this->settings_model->array_from_post(array('fullname', 'phone', 'language', 'locale'));
//die(var_dump($_FILES['avatar']['name']));
if (!empty($_FILES['avatar']['name'])) {
$this->load->model('settings_model');
$val = $this->settings_model->uploadImage("avatar");
$strpos = strpos($val, "allowed");
if($strpos==FALSE){
$this->settings_model->_table_name = 'tbl_account_details';
$this->settings_model->_primary_key = 'user_id';
$this->settings_model->save($profile_data, $user_id);
$client_id = $this->input->post('client_id', TRUE);
if (!empty($client_id)) {
$client_data = $this->settings_model->array_from_post(array('name', 'email', 'address'));
$this->settings_model->_table_name = 'tbl_client';
$this->settings_model->_primary_key = 'client_id';
$this->settings_model->save($client_data, $client_id);
}
$type = "success";
$message = lang('profile_updated');
set_message($type, $message);
redirect('client/dashboard'); //redirect page
}else{
$type= "error";
$message = "Invalid file type";
set_message($type, $message);
redirect('client/dashboard');
}
}
$profile_data['avatar'] = $val;
}
它旨在重定向到“客户端/仪表板”,但在“ profile_updated”处为空白