这是我的控制器:
public function updatedata($id)
{
//$id=$this->input->get('id');
$result['data']=$this->Form_model->displayrecordsById($id);
$this->form_validation->set_rules('fname', 'First name', 'required');
$this->form_validation->set_rules('lname', 'Last name', 'required');
$this->form_validation->set_rules('username', 'Username', 'required|min_length[5]|max_length[12]');
$this->form_validation->set_rules('email', 'Email', 'required|valid_email');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('update_records',$result);
}
else
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$this->load->library('upload', $config);
$fn=$this->input->post('fname');
$ln=$this->input->post('lname');
$un=$this->input->post('username');
$em=$this->input->post('email');
if($this->upload->do_upload('filename'))
{
$fi= $this->upload->data('file_name');
// $file = ("uploads/".$result['data']->filename);
// //delete the existing file if needed
// if (file_exists($file)) {
// unlink($file);
// }
}
else
{
$fi= $result['data']->filename;
}
$this->Form_model->updaterecords($fn,$ln,$un,$em,$fi,$id);
echo 'Successfully updated your record';
//exit();
}
}
我试图更新已经存储在数据库中的数据,它工作正常,但我面临的问题是,当我不想更新图像部分时,只说如果我想更新名字或只是电子邮件,它也可以工作很好,但后来当我在我的数据库中看到图像文件名被删除,因此图像也没有显示。
我面临的错误是这样的:
遇到 PHP 错误 严重性:通知
消息:试图获取非对象的属性
文件名:控制器/Form.php
行号:146
回溯:
文件:C:\xampp\htdocs\amit\application\controllers\Form.php 行:146 功能:_error_handler
文件:C:\xampp\htdocs\amit\index.php 行:315 功能:require_once
请任何人帮助我请我从昨天开始尝试解决此问题但我无法这样做请任何人都可以帮助我