try
{
WebRequest myrequest = WebRequest.Create(HttpContext.Current.Request["path"]);//前台js传的path,可以是远程服务器上的,也可以是本地的
WebResponse myresponse = myrequest.GetResponse();
Stream imgstream = myresponse.GetResponseStream();
System.Drawing.Image img = System.Drawing.Image.FromStream(imgstream);
MemoryStream ms = new MemoryStream();
img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
context.Response.AddHeader("Content-Length", ms.Length.ToString());
context.Response.Clear();
context.Response.ContentType = "image/jpeg";
context.Response.BinaryWrite(ms.ToArray());
context.Response.OutputStream.Flush();
context.Response.OutputStream.Close();
}
catch (Exception ex)
{
log.Error("读取图片异常:", ex);
throw ex;
}
十分感谢脚本之家:http://www.jb51.net/article/78993.htm
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。