我如何...上传图片和显示? [英] How do I... upload image and display?
本文介绍了我如何...上传图片和显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好。
我要上传图片和显示???
我上传了图像然后将其转换为二进制然后保存在数据库中然后调用,现在我只想显示图像,请帮帮我??
这里的代码如下代码
public void DisplayUploadedPhoto()
{
Class1 cl = new Class1();
string ID =会话[ IDUSER 跨度>]的ToString();
DataTable _T = cl._Get_PicInfoGV( WHERE EmailID =' + ID + ');
Byte [] bytes =( Byte [])_ T.Rows [ 0 ] [ PicData];
MemoryStream mstream = new MemoryStream(bytes);
System.Drawing.Image img1 = System.Drawing.Image.FromStream(mstream);
}
解决方案
我是这样做的: ASP.NET的通用Image-From-DB类 [ ^ ]
我解决了问题..谢谢
Class1 cl = new Class1();
string ID =会话[ IDUSER 跨度>]的ToString();
byte [] bytes =( byte [])cl._Get_PicInfoGV( WHERE EmailID =' + ID + ')。行[ 0 ] [ PicData];
string base64String = Convert.ToBase64String(bytes, 0 ,bytes.Length);
Image1.ImageUrl = data:image / png; base64, + base64String;
Hello everyone
I want to upload image and display???
I was upload the image and then convert it to binary then saved in the database and then call, Now i want only display image, please help me??
Here code below
public void DisplayUploadedPhoto()
{
Class1 cl = new Class1();
string ID = Session["IDUSER"].ToString();
DataTable _T = cl._Get_PicInfoGV(" WHERE EmailID = '" + ID + "'");
Byte[] bytes = (Byte[])_T.Rows[0]["PicData"];
MemoryStream mstream = new MemoryStream(bytes);
System.Drawing.Image img1 = System.Drawing.Image.FromStream(mstream);
}
解决方案
Here is how I do it: A generic Image-From-DB class for ASP.NET[^]
I solved the problem.. thanks
Class1 cl = new Class1(); string ID = Session["IDUSER"].ToString(); byte[] bytes = (byte[])cl._Get_PicInfoGV(" WHERE EmailID = '" + ID + "'").Rows[0]["PicData"]; string base64String = Convert.ToBase64String(bytes, 0, bytes.Length); Image1.ImageUrl = "data:image/png;base64," + base64String;
这篇关于我如何...上传图片和显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文