A generic error occurred in GDI+

puf79

New Member
Hi frnds can anyone help me to solve this problem because i am new for .net world.. The below code is working fine in local server but whenever i try to upload in server it's
getting \[quote\] "A generic error occurred in GDI+."\[/quote\]\[code\]if (FileUpload2.PostedFile.ContentType == "image/pjpeg" || FileUpload2.PostedFile.ContentType == "image/jpg" || FileUpload2.PostedFile.ContentType == "image/gif" || FileUpload2.PostedFile.ContentType == "image/jpeg" || FileUpload2.PostedFile.ContentType == "image/png") { string filename = FileUpload2.FileName; // Specify a upload directory string directory = Server.MapPath(@"datalistimg\"); // Create a bitmap in memory of the content of the fileUpload control Bitmap originalBMP = new Bitmap(FileUpload2.FileContent); // Calculate the new image dimensions int origWidth = originalBMP.Width; int origHeight = originalBMP.Height; int sngRatio = origWidth / origHeight; int newWidth = 218; int newHeight = (newWidth * origHeight) / origWidth; // Create a new bitmap which will hold the previous resized bitmap Bitmap newBMP = new Bitmap(originalBMP, newWidth, newHeight); // Create a graphic based on the new bitmap Graphics oGraphics = Graphics.FromImage(newBMP); // Set the properties for the new graphic file oGraphics.SmoothingMode = SmoothingMode.AntiAlias; oGraphics.InterpolationMode = InterpolationMode.HighQualityBicubic; // Draw the new graphic based on the resized bitmap oGraphics.DrawImage(originalBMP, 0, 0, newWidth, newHeight); // Save the new graphic file to the server newBMP.Save(directory + filename); dfn2 = @"datalistimg/" + filename; originalBMP = null; newBMP = null; oGraphics = null; fn2 = System.IO.Path.GetFileName(FileUpload2.PostedFile.FileName); string SaveLocation = Server.MapPath("event") + "\\" + fn2; fn2 = "event/" + fn2; FileUpload2.PostedFile.SaveAs(SaveLocation);\[/code\]
 
Back
Top