我正在尝试使用 codeigniter 将图像存储在 mysql 中。数据已成功插入,但我无法查看该图像。
enter code here
$this->gallery_path = realpath(APPPATH . '../img');
$config=array(
'allowed_types' => 'jpg|jpeg|gif|png',
'upload_path' => $this->gallery_path,
'max_size' =>2000
);
$this->load->library('upload',$config);
$this->upload->do_upload('business_icon');
$upload_data = $this->upload->data();
$data_ary = array(
'title' => $upload_data['client_name'],
'file' => $upload_data['file_name'],
'width' => $upload_data['image_width'],
'height' => $upload_data['image_height'],
'type' => $upload_data['image_type'],
'size' => $upload_data['file_size'],
'date' => time(),
);
$image_data=fopen($this->gallery_path.'/'.$upload_data['file_name'],'rb');
$image_data1= fread($image_data,$upload_data['file_size']);
$image_type='image/'.$upload_data['image_type'];
$insert_data=array(
'business_name'=>$this->input->post('business_name'),
'business_icon'=>$image_data1,
'icon_type'=>$image_type,
);
$this->db->insert('businesses',$insert_data);
return $this->db->insert_id();
任何人都可以帮助我解决这个问题,我如何将图像存储在数据库中并在 codeigniter 中读取它。