Welcome Guest, Not a member yet? Register   Sign In
Can't Load JPG Image from Blob Field on MySQL
#1

[eluser]Unknown[/eluser]
I know that similar questions have been replied to before but I wasn't able to adapt them for my case. So kindly I need your help.

I'm trying to load a binary JPG in a MySQL BLOB field on a form in my view. The following is the code that is not working. I only included the portions that do not work, all else is OK.

Since the content header cannot be specified inside the view because it would set all the page as JPG (and eventually nothing loads), it must be set in a dedicated function in the controller and then retrieved as an image directly. So here is my attempt:

All I receive are strange characters (meaning: it's not loaded as an image probably).

------------------------------
Controller Function Code:
------------------------------
...
function printImage($image)

{

$this->output->set_header('Content-type: image/jpg');
$this->output->set_output($image);
}

------------------------------
VIEW:
------------------------------
<?php foreach($records->result() as $row):?>
<?php $image_properties = array(

'src' => "printImage($row->picture_column_name);",
'alt' => 'exmaple',
'class' => 'post_images',
'width' => '100%',
'height' => '100%',
'title' => 'That was quite a night',
'rel' => 'lightbox',);?>

<?php endforeach; ?>
<form class="formnew">
<p>test</p>
&lt;?php img($image_properties);?&gt;
&lt;/form&gt;



Why is this not working? Appreciate your help, and happy thanks giving in advance Smile)

Arto




Theme © iAndrew 2016 - Forum software by © MyBB