I am using this code but image is not displaying full. This code is displaying one forth part of image rather full image.
<?php
echo '<img src="data:'.$image_mime_type.';base64,'.base64_encode($rs["Pic"]).'" alt="My image alt" />';
?>
Screenshot:
Try this,
$path = $rs["Pic"];
$type = pathinfo($path, PATHINFO_EXTENSION);
$data = file_get_contents($path);
$base64 = 'data:image/' . $type . ';base64,' . base64_encode($data);
//echo $base64;
echo '<img src="'.$base64.'" alt="My image alt" />';
If you use just BLOB (Guess it to be blob)
Then it is not enough to store image data which you provided in question.
You have to use instead MEDIUMBLOB or LONGBLOB
max size of
BLOB: ~ 63KB
MEDIUMBLOB: ~ 16MB
LONGBLOB: ~ 4GB
More information about the length of BLOB and other MySql fields you can see here: http://dev.mysql.com/doc/refman/5.7/en/storage-requirements.html
The four BLOB
types are TINYBLOB
, BLOB
, MEDIUMBLOB
, and LONGBLOB
. Try changing it to MEDIUMBLOB
or LONGBLOB
. I had similar issue where I was not getting full image (but, getting some part of image). This is one of the most probably reason where your image didn't get stored completely in db. After changing table structure you need to upload new/same image and see if problem resolved.