3

I'm trying to display an image, but that image type is blob.

Question:

How can I display blob data type image?

I tried with:

function getBlob() {
     $data = $this->user_model->getBlob();
     echo "<img src="base64_encode( $data['IMAGE'] )">";
}

But doesn't work.

Community
  • 1
  • 1
Secure
  • 133
  • 2
  • 2
  • 11
  • possible duplicate of [I need my PHP page to show my BLOB image from mysql database](http://stackoverflow.com/questions/13225726/i-need-my-php-page-to-show-my-blob-image-from-mysql-database) – krzysiej Feb 09 '15 at 10:01
  • i'm using that post ,but its not working ,that's why i'm asking. – Secure Feb 09 '15 at 10:02
  • Code in your question doesn't look like one in accepted answer in my link, probably this is why it doesn't work. – krzysiej Feb 09 '15 at 10:08

1 Answers1

6

You forgot the data:URI scheme (data:image/jpeg;base64,) :

Wikipedia:

The data URI scheme is a URI scheme (Uniform Resource Identifier scheme) that provides a way to include data in-line in web pages as if they were external resources [...]

Do it as follow:

echo '<img src="data:image/jpeg;base64,'.base64_encode( $data['IMAGE'] ).'"/>' 
Community
  • 1
  • 1
tomloprod
  • 7,472
  • 6
  • 48
  • 66