i write bellow code to display images from database
You also might use base64 encoding to build in the image. Like
<img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAWgBaAAD/4gxYSUNDX1BST0ZJTEUAAQEAAAxITGlubwIQAAB..." />
UPDATE, base64 encoding example
You can do that easily:
<?php
$imageId = intval($_GET["id"]);
$query = mysql_query("SELECT img FROM images WHERE id = ". $imageId);
$row = mysql_fetch_array($query);
$mime = null;
// place $type init. here
if ($type=="pjpeg") // <<< where do you get $type btw?
$mime = "image/jpeg";
$b64Src = "data:".$mime.";base64," . base64_encode($row["img"]);
echo '<img src="'.$b64Src.'" alt="" />';
?>
As above
+ be sure to pass the replace = true
parameter to the header function.
header( 'Content-Type: image/jpeg', true );
jpeg
is not a valid Content-Type, it should be image/jpeg