我已经上传图像数据库,但是当我想显示它的图像不能显示..我不知道它为什么不能显示..可能在我的编码有问题..你可以帮助我??图片无法显示
upload.php的
<?php
$id = $_POST['account'];
$code = $_POST['code'];
$price = $_POST['price'];
echo $file = $_FILES['image']['tmp_name'];
if (!isset($file))
echo "Please select an image.";
else
{
$image = addslashes (file_get_contents($_FILES['image']['tmp_name']));
$image_name = addslashes ($_FILES['image']['name']);
$image_size = getimagesize($_FILES['image']['tmp_name']);
if($image_size==FALSE)
echo "That's not an image.";
else
{
if (!$insert = mysql_query("INSERT INTO menu
VALUES('$code','$price','$image','$id')"))
echo "Problem uploading images.";
else
{
$lastid = $code;
echo "Image uploaded.<p />Your image:<p /><img src=get.php?id=$lastid>";
}
}
}
?>
get.php
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("food", $con);
$id = addslashes($_REQUEST['FoodId']);
$image = mysql_query("SELECT * FROM menu WHERE FoodId=$id");
$image = mysql_fetch_assoc($image);
$image = $image['image'];
header("Content-type: image/jpeg");
echo $image;
?>
你可以在这里粘贴什么错误显示? –
为什么你将图像内容存储在数据库中?保存图像的列的类型是什么? –
BLOB DATA TYPE .. – user1683166