title: asp.net : A generic error occurred in GDI+
body: <p>I create an asp.net 4.0 web application which has a web service for uploading images. I am uploading images by sending the image in form of Base64 string from my mobile app to the web service.</p>
  
  <p>Following is my code:</p>
  
  <pre><code>public string Authenticate(string username, string password, string fileID, string imageData)
      {
          Dictionary&lt;string, string&gt; responseDictionary = new Dictionary&lt;string, string&gt;();
          bool isAuthenticated = true; // Set this value based on the authentication logic
  
          try
          {
              if (isAuthenticated)
              {
                  UploadImage(imageData);
  
                  string result = "success";
                  var message = "Login successful";
  
                  responseDictionary["status"] = result;
                  responseDictionary["message"] = message;
              }
          }
          catch (Exception ex)
          {
  
              responseDictionary["status"] = ex.Message;
              responseDictionary["message"] = ex.StackTrace;
          }
  
          return new JavaScriptSerializer().Serialize(responseDictionary);
      }
  
      private void UploadImage(string uploadedImage)
      {
          // Convert Base64 String to byte[]
          byte[] imageBytes = Convert.FromBase64String(uploadedImage);
          MemoryStream ms = new MemoryStream(imageBytes, 0, imageBytes.Length);
  
          System.Drawing.Bitmap bitmap = (System.Drawing.Bitmap)Image.FromStream(ms);
  
          string uploadPath = Server.MapPath("..\\uploads\\") + DateTime.Now.Ticks.ToString() + ".jpeg";
          ms.Close();
  
          bitmap.Save(uploadPath, System.Drawing.Imaging.ImageFormat.Jpeg);
          bitmap.Dispose();
      }    
  </code></pre>
  
  <p>This code was working fine on my local ASP.NET development server and I was able to see the uploaded image in my "uploads" directory. However, after transferring the code to the FTP directory, I am now getting the following error:</p>
  
  <p><code>A generic error occurred in GDI+</code></p>
  
  <p>I have checked that the upload directory has proper permission by creating a dummy .aspx page and creating a text file on page_load, and it works fine. </p>
  
  <p>Even after doing google search, I was not able to solve this problem. Can anybody help me fixing this?</p>
  
  <p>Thanks a lot in advance.</p>