Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/299.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 将图像作为blob类型插入数据库-Codeigniter_Php_Codeigniter - Fatal编程技术网

Php 将图像作为blob类型插入数据库-Codeigniter

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

我需要使用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 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(以函数中的本地为例)