[英]how do I display a BLOB image through php database
i have tried to display an image from the php database and every time i load this code it takes me to a new page and it give me "image not able to be displayed" thing 我试图显示来自php数据库的图像,并且每次我加载此代码时,它会将我带到新页面,并且显示“图像无法显示”的内容
<?php
while($data= mysql_fetch_assoc($query)){
?>
<img src=<?php
$image=$data['image'];
header("content-type: image/jpeg");
echo $image;
?>
/>
<?php } ?>
You have to create a php file, for example image.php. 您必须创建一个php文件,例如image.php。 Inside it you can put something like that:
在其中可以放入类似的内容:
<?php
//Your code to call database for image id (from _GET['id']), for instance:
$image_id = $_GET['id'];
$data = mysql_query("Select image from images where id = $image_id");
while($data = mysql_fetch_assoc($query)){
$image=$data['image'];
header("content-type: image/jpeg");
echo $image;
}
?>
Then, in your view, you can do: 然后,您可以执行以下操作:
<img src="image.php?id=IMAGE_ID" />
Greetings! 问候!
将其发送到php上的其他页面,并像这样调用它
<img src="differentpage.php?id=<?php echo id ?>">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.