C#

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

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-05
  • 2022-12-23
  • 2021-12-18
  • 2021-11-08
  • 2022-03-01
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案