无法显示存储在数据库中的BLOB [英] Can't display BLOB stored in database

查看:117
本文介绍了无法显示存储在数据库中的BLOB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我想要转换存储在我的数据库中的blob格式的图像时,我遇到了问题。
当iç只回显$ content时,我可以实际看到打印出的blob文件,这样我的查询就没有问题了。

I've got an problem when I want to convert an image in blob format stored in my database. When iç just echo $content I can actualy see the blob file printed out so there is no problem with my queries.

问题是我的代码只有显示损坏的图像而不是数据库中的图像。
有谁知道如何正确显示图像?

The problem is that my code only displays an broken image instead of the Image in the database. Does anyone know how to display the image properly?

提前致谢

        $content = mysql_result($result,$i,'Image');




        echo '<img src="data:image/jpeg;base64,<?php echo base64_encode($content); ?>" width="100" />';


推荐答案

最好的办法是使用单独的页面显示如下图像:

The best way to do it would be to use a separate page to display the image like the following:

<?php
header("Content-Type: image/jpeg");
// Do your query
$content = mysql_result($result,$i,'Image');
echo $content;
?>

然后在另一页中

<img src="pagetodisplaytheimage.php" width="100"/>

这个问题也回答了这个问题:如何显示存储在MySql数据库中的BLOB图像?

It's also answered in this question: How to display an BLOB image stored in MySql database?

这篇关于无法显示存储在数据库中的BLOB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆