可能重复:
How can I store and retrieve images from a MySQL database using PHP?
我已经在blob字段中完美地上传了我的图片但是我无法显示图像我使用了以下代码,但它无法正常工作:
<?php
$username = "root";
$password = "";
$host = "localhost";
$database = "bakery";
@mysql_connect($host, $username, $password) or die("Can not connect to database: ".mysql_error());
@mysql_select_db($database) or die("Can not select the database: ".mysql_error());
$id = 3 ;
if($id==3){
$query = mysql_query("SELECT img FROM pic WHERE Desc='".$id."'");
$row = mysql_fetch_array($query);
$content = $row['image'];
header('Content-type: image/jpg');
echo $content;
}
?>