veritabanından yüklenen görüntü görünmüyor

0 Cevap

guys. I tried to load image stored in mysql blob field with php, but the image does not show correctly. In firebug, I got these infos: get-image.php Dimensions0 × 0File size5.35KBMIME typeimage/jpeg

İşte benim kod

HTML

<html>
  <head>
    <title>Demo of Database Image in a page</title>
  </head>
  <body>
    Here is your picture:<br>
    img src=get-image.php?id=1 width=400 height=300><br>
  </body>
</html>

PHP

<?php
include "db.php";
$conn = OpenDbConnection();
$key = $_GET["id"];
$tkey = "" . $key . "";
$strsql = "SELECT * FROM `images` WHERE `image_id` = " . $tkey;
$rs = mysql_query($strsql, $conn) or die(mysql_error());
if (!($row = mysql_fetch_array($rs))) {
    die("File not exists.");
}
header("Content-type: image/jpeg");
echo $row["content"];
mysql_free_result($rs);
mysql_close($conn);  
?>

Birisi benim koduyla yanlış olduğunu söyle lütfen?

0 Cevap