I am trying to insert image in DB but for some reasons I could not retrieve it. I am using BLOB type for images in database.
Code I am using to upload image. Once I save image in db, in "IMAGE" column I get file image-01.bin
if (isset($_POST["submit"]) {
$id= $_GET["id"];
$image = $_POST["image"];
$stmt=$conn->prepare("INSERT INTO db (id, image) VALUES (:id, :image)");
$stmt->bindParam(:id, $id);
$stmt->bindParam(:image, $image);
$stmt->execute();
}
Code I am using to print image in web page.
$stmt = "Select Id, Image from db where id = $id LIMIT 0,1"
$q = $conn->query($stmt);
while ($r = $q ->fetch():
echo "<img src ='",$r[Image],"' width='100' height='100' />";
endwhile;