0

How to print or echo an image with img src on a HTML page where the image is saved in database with type longblob. Any suggestion will be appreciated. Thank you.

Tapash
  • 27
  • 3
  • 10
  • I was looking for this, I don't think its possible unless you take the image and save it to a temp folder/filename then add the URL to it to the page. – Theresa Forster Apr 18 '16 at 06:12
  • Maybe I am also thinking to do that, but if anybody can suggest any better idea. It will be very helpful. – Tapash Apr 18 '16 at 06:15
  • This [link](http://stackoverflow.com/questions/1207190/embedding-base64-images) Shows base64 images encoded via the URI but Tapash's way is much more common. (You don't actually need to save it to a local file though). – Stephen Fulton Apr 18 '16 at 06:19

1 Answers1

0

Ohh..!!! Thank you Stephen. I finally got the answer. It's simply as

<img src="data:image/jpeg;base64,<?php echo base64_encode($image->picture); ?>" alt="Responsive image">

And it is working.

Tapash
  • 27
  • 3
  • 10