PHP检索VARBINARY&显示为图像 [英] PHP retrieve VARBINARY & display as an image

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

问题描述


  1. 使用C#创建图像

  2. 将其转换为字节[] - ------> 这就是我的做法

  3. 然后将其发送到MySQL并将其存储在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 );

之后我不知道该怎么办。互联网没有提供关于此的mch信息。请帮助

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

推荐答案

您已存储字符串 System.Byte [] 进入要将图像文件的二进制数据存储到的数据库字段中。修复插入代码并将普通字节放入数据库。在PHP中,然后将其编码为base64以输出它:

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']);?>" />

这应该可以胜任。

这篇关于PHP检索VARBINARY&amp;显示为图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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