Not displaying a blob image

陌路散爱 提交于 2019-12-24 13:19:17

问题


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

    }
}

} ?>

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


回答1:


Try Like this.

For Inserting into DB

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

For Accessing image From Blob

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


来源:https://stackoverflow.com/questions/31964564/not-displaying-a-blob-image

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