System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+. at System.Drawing.Image.Save
-
Hi, I am trying to upload an image and resize it. the image being uploaded will be saved in photos and thumbs directory. I have given network service and iusr_machinename write access to both folders. the upload works fine in local machine its just when i try to upload via a remote server i get error "A generic error occurred in GDI+." below are my codes for upload click event. please help
try
{
String file = "";
String thumb = "";
if (flUpload.PostedFile.ContentLength > 0)
{
file = flUpload.FileName;
thumb = "";
String[] strNew = file.Split('.');
strNew[0] = DateTime.Now.Ticks.ToString();
file = strNew[0] + "." + strNew[1];
thumb = strNew[0] + "_t." + strNew[1];ImageName = file; ImagePath = Server.MapPath("~/photos") +"\\\\"+ ImageName; Response.Write(ImagePath); ImageThumbName = thumb; ImageThumbPath = Server.MapPath("~/thumbs") + "\\\\" + ImageThumbName; Response.Write(ImageThumbPath); using (System.Drawing.Image Img = new Bitmap(flUpload.FileContent)) { Size ThumbNailSize = NewImageSize(Img.Height, Img.Width, 100); Size ImageSize = NewImageSize(Img.Height, Img.Width, 500); using (System.Drawing.Image ImgThnail = new Bitmap(Img, ThumbNailSize.Width, ThumbNailSize.Height)) { ImgThnail.Save(ImageThumbPath, Img.RawFormat); ImgThnail.Dispose(); } using (System.Drawing.Image Img1 = new Bitmap(Img, ImageSize.Width, ImageSize.Height)) { Img1.Save(ImagePath, Img.RawFormat); Img1.Dispose(); } Img.Dispose(); } }
public Size NewImageSize(int OriginalHeight, int OriginalWidth, double FormatSize)
{
Size NewSize; double tempval;if (OriginalHeight > FormatSize &a
-
Hi, I am trying to upload an image and resize it. the image being uploaded will be saved in photos and thumbs directory. I have given network service and iusr_machinename write access to both folders. the upload works fine in local machine its just when i try to upload via a remote server i get error "A generic error occurred in GDI+." below are my codes for upload click event. please help
try
{
String file = "";
String thumb = "";
if (flUpload.PostedFile.ContentLength > 0)
{
file = flUpload.FileName;
thumb = "";
String[] strNew = file.Split('.');
strNew[0] = DateTime.Now.Ticks.ToString();
file = strNew[0] + "." + strNew[1];
thumb = strNew[0] + "_t." + strNew[1];ImageName = file; ImagePath = Server.MapPath("~/photos") +"\\\\"+ ImageName; Response.Write(ImagePath); ImageThumbName = thumb; ImageThumbPath = Server.MapPath("~/thumbs") + "\\\\" + ImageThumbName; Response.Write(ImageThumbPath); using (System.Drawing.Image Img = new Bitmap(flUpload.FileContent)) { Size ThumbNailSize = NewImageSize(Img.Height, Img.Width, 100); Size ImageSize = NewImageSize(Img.Height, Img.Width, 500); using (System.Drawing.Image ImgThnail = new Bitmap(Img, ThumbNailSize.Width, ThumbNailSize.Height)) { ImgThnail.Save(ImageThumbPath, Img.RawFormat); ImgThnail.Dispose(); } using (System.Drawing.Image Img1 = new Bitmap(Img, ImageSize.Width, ImageSize.Height)) { Img1.Save(ImagePath, Img.RawFormat); Img1.Dispose(); } Img.Dispose(); } }
public Size NewImageSize(int OriginalHeight, int OriginalWidth, double FormatSize)
{
Size NewSize; double tempval;if (OriginalHeight > FormatSize &a
-
Check if you have access rights to save to the shared / network folder.
There are only 10 types of people in this world — those who understand binary, and those who don't.
-
what do you mean. not sure how i do that as the website is hosted remotely and its with the hosting provider.