A generic error occurred in GDI+. 上传图片报错

代码就不说了,因为本地测试 ok,

服务端 就不行 ,服务器 环境 阿里云 win2008 r2  64 位

原因 是我没有这是 文件加权限 :

技术分享

左边 的 少了 权限~

代码 :含义是 网络图片 裁剪 保存 到本地 ,本地 再 存储 到 七牛 云存储。

  public static string Crop(string ImgUrl, int Width, int Height, int X, int Y)
    {
      string path = "C:\\DescripttionImg\\";
      string Temp = "";
      string path_Temp = "";
      try
      {

        if (ImgUrl.IndexOf(?) > 0)
        {
          Temp = ImgUrl.Remove(ImgUrl.IndexOf(?));
          Temp = "Head_" + Temp.Substring(Temp.LastIndexOf(/) + 1);
        }
        else
        {
          Temp = "Head_" + ImgUrl.Substring(ImgUrl.LastIndexOf(/) + 1);
        }


        WebRequest WebReq = WebRequest.Create(ImgUrl);
        WebReq.Method = "GET";
        var img = System.Drawing.Image.FromStream(WebReq.GetResponse().GetResponseStream());
        using (System.Drawing.Image OriginalImage = img)
        {
          using (Bitmap bmp = new Bitmap(Width, Height))
          {
            bmp.SetResolution(OriginalImage.HorizontalResolution, OriginalImage.VerticalResolution);
            using (Graphics Graphic = Graphics.FromImage(bmp))
            {
              Graphic.SmoothingMode = SmoothingMode.AntiAlias;
              Graphic.InterpolationMode = InterpolationMode.HighQualityBicubic;
              Graphic.PixelOffsetMode = PixelOffsetMode.HighQuality;
              Graphic.DrawImage(OriginalImage, new Rectangle(0, 0, Width, Height), X, Y, Width, Height, GraphicsUnit.Pixel);
              //MemoryStream ms = new MemoryStream();
              path_Temp = path + Temp;
              bmp.Save(path_Temp);
              WebReq.Abort();
              //return ms.GetBuffer();
            }
          }
        }
        Qiniu_API.PutFile(path_Temp, Temp);
        return string.Format("http://{0}/{1}", Qiniu_API.Domain, Temp);
        // 
      }

      catch (Exception ex)
      {
        KT_Product_ShowEntities tempconn = new KT_Product_ShowEntities();

        tempconn.Err_Log.Add(new Err_Log()
        {
          CreateTime = DateTime.Now,
          form_no = "",
          Msg = ex.Message,
          StackTrace = ex.StackTrace,
          sys_user = "",
          TargetSite = ex.TargetSite.ToString(),
          UserName = "mail"
        });
        tempconn.SaveChanges();

        throw (ex);
      }
      finally
      {

      }
    }

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。