不显示斑点图像 [英] Not displaying a blob image

查看:82
本文介绍了不显示斑点图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我在从数据库显示BLOB时遇到了一个小问题,我尝试了一切,但没有结果,只有一些丑陋的字符,我知道这有点愚蠢,但是让我发疯,这是代码:

so i'm having a small problem in displaying a BLOB from my database , I tried everything but with no results , just some ugly characters , I know it's something silly but it drives me crazy , here is the code:

<?php
conect..
//collect
 if(isset($_POST['search'])) {
$searchq = $_POST['search'];

$query = mysql_query("SELECT * FROM thinking_search.search WHERE title LIKE '%$searchq%' OR keywords LIKE '%$searchq%'");
$count = mysql_num_rows($query);
if($count == 0) {
    $output = 'There are no articles on this topic...';
}else{
      while($row = mysql_fetch_array($query)) {
          $title = $row['title'];
          $keywords = $row['keywords'];
          $id = $row['id'];
          $link = $row['link'];
          $picture = $row['picture'];
          $description = $row['description'];

          $output .='<div id="u"><a href="'.$link.'"><img src="data:image/jpeg;base64,'.base64_encode( $picture ).'"/> <div id="title">'.$title.' </div> <div id="key">'.$keywords.'</div><div id="description">'.$description.'</div></a></div>';

    }
}

} ?>

在我的数据库图片被设置为'blob'的情况下,其余的很简单,我在页面上也有一个print("$ output"),但是与此无关,我希望有人可以自由地帮助:D

In my database picture is set to 'blob' , the rest is simple , I also have a print("$output") on my page but that has nothing to do with this , I hope there could be someone free to help :D

推荐答案

像这样尝试.

用于插入数据库

$image = addslashes(file_get_contents($_FILES['images']['tmp_name']));

用于从Blob访问图像

For Accessing image From Blob

    echo '<img src="data:image/jpeg;base64,'.base64_encode( $result['image'] ).'"/>';

这篇关于不显示斑点图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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