2012-02-25 02:51
浏览 55


i am

  1. Creating an image with C#
  2. Converting it to Byte[] -------> This is how i am doing it
  3. then Sending it to MySQL and storing it in VARBINARY

the problem is now I don't know how to retrieve it TO display it as an image

$query = mysql_query("SELECT * FROM sad_img WHERE ss_id='1'");
if( mysql_num_rows( $query ) > 0 )
$ui = mysql_fetch_assoc( $query );

and after that i have no clue, what to do. The internet is not providing mch information about this. Please help

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dqwh1205 2012-02-25 04:30

    You have stored the string System.Byte[] into the database field where you wanted to store the binary data of the image file into. Fix the insert code and put the plain bytes into the database. In PHP then encode it as base64 to output it:

    <img src="data:image/jpeg;base64,<?php echo base64_encode($ui['screenshot']);?>" />

    This should do the job.

    点赞 打赏 评论
  • duanchongchu5177 2016-08-17 08:12

    use this code for base64 type image fileds

    <img class="w3-hover-opacity"src="data:image/jpeg;base64,'.base64_encode( $row['Photo'] ).'"
                            width="120" height="120" onClick="onClick(this)" style="cursor:pointer border-raduis:1px;">';

    点赞 打赏 评论

相关推荐 更多相似问题