在asp.net中保存图像标记中的图像 [英] save image from image tag in asp.net
本文介绍了在asp.net中保存图像标记中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好朋友
i一直在努力'保存图片来自< asp:image tag'我只是一点点想法HttpWebRequest会帮助我但我不能实现这个。
plz给出一些关于这个的链接或想法或样本
谢谢
hello friends
i have struggle with to 'save the image from <asp:image tag' i have just little idea HttpWebRequest will help me but i could not be implementing this.
plz give some link or idea or sample regarding this
thanks
推荐答案
听到的是解决方案我的问题
hear is solution of my question
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
txtBarCodeText.Focus();
var barcode = new Code39BarCode()
{
BarCodeText = "HELRE WORLD",
BarCodeWeight = BarCodeWeight.Medium,
Height = 100
};
byte[] fileContents = barcode.Generate();
string filePath = Server.MapPath("~/barcode.gif");
File.WriteAllBytes(filePath, fileContents);
string filepath1 = Server.MapPath("~/barcode.gif");
string fn= Guid.NewGuid()+filepath1.Substring(filepath1.LastIndexOf("."));
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://localhost:1231/WebFormsDemo/barcode.gif");
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
System.Drawing.Image img = System.Drawing.Image.FromStream(response.GetResponseStream());
//imgbar is folder name which is stored the new image
img.Save(Server.MapPath("imgbar/")+fn);
}
这篇关于在asp.net中保存图像标记中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文