当我想更新数据库表中有上传图片的记录时,无法上传图片但所有其他数据都已成功更新 这是更新功能:
$config['upload_path'] = './img/products/';
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$config['max_size'] = '0';
$config['max_width'] = '0';
$config['max_height'] = '0';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('admin/admin_header_view');
$this->load->view("admin/admin_menu_view");
$this->load->view('admin/admin_rewarding_view', $error);
$this->load->view('admin/admin_footer_view');
}
else
{
$data = array('upload_data' => $this->upload->data());
$filename = $data['upload_data']['file_name'];
$data= array(
'reward' => $this->input->post('reward'),
'amount_of_points' => $this->input->post('amount_of_points'),
'img' => $filename
);
$this->db->where('id',$this->input->post('id'));
$this->db->update('rewards',$data);
redirect("admin/rewarding_system");
}
答案 0 :(得分:0)
if ( ! $this->upload->do_upload($this->input->post('upload_name_attr')) //or however you are getting this file to the server
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('admin/admin_header_view');
$this->load->view("admin/admin_menu_view");
$this->load->view('admin/admin_rewarding_view', $error);
$this->load->view('admin/admin_footer_view');
}