Can't display BLOB stored in database

早过忘川 提交于 2019-12-13 19:18:58

问题


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?

Thanks in advance

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




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

回答1:


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;
?>

Then in another page do

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

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



来源:https://stackoverflow.com/questions/26819999/cant-display-blob-stored-in-database

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!