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

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -