![](/img/trans.png)
[英]How to display image on codeigniter that is stored in oracle database as BLOB type?
[英]Insert image in database as blob type - 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 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
謝謝。
在您的代碼中,您有與變量有關的錯字。 看來您可能將variable
稱為function
。
即使您要從函數訪問值,也應將其寫為$ 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);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.