Php 将图像作为blob类型插入数据库-Codeigniter
我需要使用codeigniter在数据库中以blob类型存储图像。我不想将图像上载到文件夹中。我只是想将图像以blob的形式存储在db中 我的模型里有这个Php 将图像作为blob类型插入数据库-Codeigniter,php,codeigniter,Php,Codeigniter,我需要使用codeigniter在数据库中以blob类型存储图像。我不想将图像上载到文件夹中。我只是想将图像以blob的形式存储在db中 我的模型里有这个 public function insert_user() { $get_image = $this->input->post(file_get_contents($_FILES['imgProfile']['tmp_name'])); //imgProfile is the name of the imag
public function insert_user()
{
$get_image = $this->input->post(file_get_contents($_FILES['imgProfile']['tmp_name'])); //imgProfile is the name of the image tag
$insert_values = array(
'first_name' => $this->input->post('FirstName'),
'last_name' => $this->input->post('LastName'),
'profile_image' => $this->$get_image
);
$insert_qry = $this->db->insert('user', $insert_values);
}
我的控制器包含
public function new_user()
{
$this->user_model->insert_user(); //user_model is the model name
}
错误:
Fatal error: Cannot access empty property in C:\xampp\htdocs\CI\system\core\Model.php on line 52
谢谢。您的代码中有与变量相关的打字错误。似乎您可能正在将
变量
作为函数
调用
即使要从函数中访问值,也应将其写入$this->get_image()变量$this->get_image而不是$this->$get_image
public function insert_user()
{
$get_image = $this->input->post(file_get_contents($_FILES['imgProfile']['tmp_name'])); //imgProfile is the name of the image tag
$insert_values = array(
'first_name' => $this->input->post('FirstName'),
'last_name' => $this->input->post('LastName'),
'profile_image' => $get_image //its a variable
);
$insert_qry = $this->db->insert('user', $insert_values);
}
什么是Model.php中的L52?引用$this->$getimage是错误的,它应该是$this->getimage或simple$getimage(以函数中的本地为例)