if (fileUploadImage.HasFile) { int fileSize = fileUploadImage.PostedFile.ContentLength; if (fileSize > Convert.ToInt32(ConfigurationManager.AppSettings["fileSize"])) { lblUploadImage.Visible = true; } else { String fileName = fileUploadImage.FileName.ToString();//Substring (0,fileUploadImage.FileName.IndexOf(".")); string fileNameUrl = ConfigurationManager.AppSettings["imagepath"] + GenerateUniqueFileName(txtFname.Text, Path.GetExtension(fileName)); Bitmap upBmp = (Bitmap)Bitmap.FromStream(fileUploadImage.PostedFile.InputStream); Bitmap newBmp = new Bitmap(50,50, System.Drawing.Imaging.PixelFormat.Format24bppRgb); newBmp.SetResolution(72, 72); Graphics newGraphic = Graphics.FromImage(newBmp); try { newGraphic.Clear(Color.White); newGraphic.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; newGraphic.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; newGraphic.DrawImage(upBmp, 500, 100, 500, 100); newBmp.Save(MapPath(fileNameUrl)); //Show the uploaded resized picture in the image control imgProfile.Src = fileNameUrl; lblUploadImage.Visible = true; } catch(Exception exp) { } // fileUploadImage.SaveAs(Server.MapPath(fileNameUrl)); // HiddenField1.Value = fileNameUrl; // imgProfile.Src = fileNameUrl; // lblUploadImage.Visible = false; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)