title: C# A generic error occurred in GDI+ after save cropped image
body: <p>I have two steps for upload and save images, In the first step, image is uploaded and a preview shown to the user for cropping and in the second step with a JQuery plugin user select intended area and click crop image button.</p>
  <p>At bellow you can see <code>CropImage()</code> Action.</p>
  <pre><code>[HttpPost]
  public async Task&lt;ActionResult&gt; CropImage(UploadImage data)
  {
      string fileName = data.fileName;
      string path;
  
      path = Path.Combine(Server.MapPath(&quot;~/Images/UsersImages/&quot;), fileName);
      data.url = &quot;https://example.com/Images/UsersImages/&quot; + fileName + &quot;?crop=&quot; + data.x1 +
                 &quot;,&quot; + data.y1 + &quot;,&quot; + data.x2 + &quot;,&quot; + data.y2 + &quot;&amp;&amp;width=309&amp;&amp;height=411&amp;mode=max&quot;;
  
                    
      Bitmap img = new Bitmap(data.GetStreamFromUrl());
      img.Save(path);
    
  }
  </code></pre>
  <p>And here is <code>UploadImage</code> class:</p>
  <pre><code>public class UploadImage
  {
      public string url { get; set; }
      public string fileName { get; set; }
      public string x1 { get; set; }
      ...
  
  
      public Stream GetStreamFromUrl()
      {
          byte[] imageData;
          using (var wc = new System.Net.WebClient())
              imageData = wc.DownloadData(url);
          return new MemoryStream(imageData);
       }
  }
  </code></pre>
  <p>If I want to save cropped image I get the following error:</p>
  <blockquote>
  <p>A generic error occurred in GDI+</p>
  <p>InnerException: at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams)</p>
  </blockquote>
  <p><em>I enable all permission for write on server.</em></p>
  <p>What should I do to save cropped images?</p>