2015-04-23 62 views
-1

我需要使用codeigniter将图像作为Blob类型存储在数据库中。我不想将图片上传到文件夹中。我只是想将图像作为blob存储在数据库中。以blob类型在数据库中插入图像 - Codeigniter

我有这个在我的模型

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 

感谢。

+0

什么是Model.php中的L52? – Florian

+0

参考$ this - > $ getimage是错误的,它应该是$ this-> getimage或者简单的$ getimage(在本地函数中使用) –

回答

2

在你的代码中,你有与变量相关的错字。看起来你可能会打电话给你的variable作为function

即使如果你想从一个函数,那么它应该被写成$这个 - > get_image()和变量$这个 - 访问值> get_image没有$本 - > $ 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);  
    } 
相关问题