0
I have searched several times but could not find a solution, I need to display an image that was saved as BLOB in the database.
Part of the code that saves to the database and displays the data
function manage_report($param1 = '', $param2 = '', $param3 = '')
{
if ($this->session->userdata('doctor_login') != 1)
redirect(base_url() . 'index.php?login', 'refresh');
if ($param1 == 'create') {
$data['img_principal'] = $this->input->post('img_principal');
$this->db->insert('report', $data);
$this->session->set_flashdata('flash_message', get_phrase('report_created'));
redirect(base_url() . 'index.php?doctor/manage_report', 'refresh');
}
if ($param1 == 'edit' && $param2 == 'do_update') {
$data['img_principal'] = $this->input->post('img_principal');
$this->db->where('report_id', $param3);
$this->db->update('report', $data);
$this->session->set_flashdata('flash_message', get_phrase('account_updated'));
redirect(base_url() . 'index.php?doctor/manage_report', 'refresh');
} else if ($param1 == 'edit') {
$page_data['edit_profile'] = $this->db->get_where('report', array(
'report_id' => $param2
))->result_array();
}
$page_data['page_name'] = 'manage_report';
$page_data['page_title'] = get_phrase('manage_report');
$page_data['reports'] = $this->db->get('report')->result_array();
$this->load->view('index', $page_data);
}
As I’m trying to show on the . html page
<img src="<?php echo $row['img_principal']; ?>"/>
database
CREATE TABLE `report` ( `report_id` int(11) NOT NULL, `img_principal` blo NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
Would it be possible to update the post making clear the part that recovers the BLOB, and the type of data from the field? If it’s an image, you need a separate PHP to serve it (and avoid scamming with Base64, which are only good for small images)
– Bacco
Here is an idea, but honestly, the answers in general on this subject on the site are leaving something to be desired: https://answall.com/questions/142841/70
– Bacco
I’ll check @Bacco, thank you!
– Lorena