php - How to view get image back from MySQL database -
i have uploaded image in database. datatype blob. want view image in browser. have written following code not generating image. kindly check it.
thanks
<?php include 'connect.php'; //$id= $_get['product_id']; $query_images = "select image product_images product_id=121"; if (!$query_images_result = mysql_query($query_images)) { echo mysql_error(); } else { $fetch_images = mysql_fetch_array($query_images_result); $print_images = $fetch_images['image']; header('content-type:image/jpeg'); echo $print_images; } ?>
file 2
<body> <img src='single_product_image_show.php' alt="image" /> </body>
maybe this? might wanna use base64 encoding build in image
fyi: not tested.
$sql = "select `image` `product_images` `product_id`=121 limit 1"; $query_images_result = mysql_query($sql); if (!$query_images_result) { echo mysql_error(); } else { list($print_images) = mysql_fetch_array($query_images_result); $base64source = "data:image/jpeg;base64," . base64_encode($print_images); echo '<img src="'.$base64source.'" alt="" />'; }
Comments
Post a Comment