error while resizing uploaded image
-
Hi, when uploading a image to a server, I get error saying directory not found. I am guessing its because its trying to find a path of users computer path in server and failing. in my localhost this works fine. how can i modify below code so that below line System.Drawing.Image.FromFile(System.IO.Path.GetFullPath(flUpload.PostedFile.FileName)) maps to server. is there anyway i can get it working before actually uploading the original image to the server? thank you
using (System.Drawing.Image Img = System.Drawing.Image.FromFile(System.IO.Path.GetFullPath(flUpload.PostedFile.FileName)))
{
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(); }
-
Hi, when uploading a image to a server, I get error saying directory not found. I am guessing its because its trying to find a path of users computer path in server and failing. in my localhost this works fine. how can i modify below code so that below line System.Drawing.Image.FromFile(System.IO.Path.GetFullPath(flUpload.PostedFile.FileName)) maps to server. is there anyway i can get it working before actually uploading the original image to the server? thank you
using (System.Drawing.Image Img = System.Drawing.Image.FromFile(System.IO.Path.GetFullPath(flUpload.PostedFile.FileName)))
{
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(); }
Check this link : http://forums.asp.net/t/1079883.aspx[^] Note: Please post the questions related to asp.net in the correct forum.
"Never put off until run time what you can do at compile time." - David Gries, in "Compiler Construction for Digital Computers", circa 1969.