protected void btnBackImage_Click(object sender, EventArgs e) { try { string productid = Request.QueryString["product"]; if (productid != null) { string ImageFile = ""; if (UploadImage.HasFile) { string imgPath = "~/Upload/images/"; string thumbPath = "~/Upload/thumbnails/"; string smallPath = "~/Upload/small/"; ImageFile = Path.GetFileName(Server.MapPath(UploadImage.PostedFile.FileName)); ImageFile = System.DateTime.Now.ToString("yyyyMMddHHmmss") + "-back-" + ImageFile; thumbPath = thumbPath + ImageFile; System.Drawing.Bitmap bmpUploadedImage = new System.Drawing.Bitmap(UploadImage.PostedFile.InputStream); System.Drawing.Image objImage = ScaleImage(bmpUploadedImage); objImage.Save(Server.MapPath(thumbPath), ImageFormat.Png); smallPath = smallPath + ImageFile; System.Drawing.Image objImage2 = ScaleImage2(bmpUploadedImage); objImage2.Save(Server.MapPath(smallPath), ImageFormat.Png); imgPath = imgPath + ImageFile; UploadImage.SaveAs(MapPath(imgPath)); } else { ImageFile = lblImage.Text; } string ImageFile2 = ""; if (UploadImage2.HasFile) { string imgPath = "~/Upload/images/"; string thumbPath = "~/Upload/thumbnails/"; string smallPath = "~/Upload/small/"; ImageFile2 = Path.GetFileName(Server.MapPath(UploadImage2.PostedFile.FileName)); ImageFile2 = System.DateTime.Now.ToString("yyyyMMddHHmmss") + "-back-" + ImageFile2; thumbPath = thumbPath + ImageFile2; System.Drawing.Bitmap bmpUploadedImage = new System.Drawing.Bitmap(UploadImage2.PostedFile.InputStream); System.Drawing.Image objImage = ScaleImage(bmpUploadedImage); objImage.Save(Server.MapPath(thumbPath), ImageFormat.Png); smallPath = smallPath + ImageFile2; System.Drawing.Image objImage2 = ScaleImage2(bmpUploadedImage); objImage2.Save(Server.MapPath(smallPath), ImageFormat.Png); imgPath = imgPath + ImageFile2; UploadImage2.SaveAs(MapPath(imgPath)); } else { ImageFile2 = lblImage2.Text; } string ImageFile3 = ""; if (UploadImage3.HasFile) { string imgPath = "~/Upload/images/"; string thumbPath = "~/Upload/thumbnails/"; string smallPath = "~/Upload/small/"; ImageFile3 = Path.GetFileName(Server.MapPath(UploadImage3.PostedFile.FileName)); ImageFile3 = System.DateTime.Now.ToString("yyyyMMddHHmmss") + "-back-" + ImageFile3; thumbPath = thumbPath + ImageFile3; System.Drawing.Bitmap bmpUploadedImage = new System.Drawing.Bitmap(UploadImage3.PostedFile.InputStream); System.Drawing.Image objImage = ScaleImage(bmpUploadedImage); objImage.Save(Server.MapPath(thumbPath), ImageFormat.Png); smallPath = smallPath + ImageFile3; System.Drawing.Image objImage2 = ScaleImage2(bmpUploadedImage); objImage2.Save(Server.MapPath(smallPath), ImageFormat.Png); imgPath = imgPath + ImageFile3; UploadImage3.SaveAs(MapPath(imgPath)); } else { ImageFile3 = lblImage3.Text; } int result = 0; result = obj_product.AddOtherProductImage(productid, ImageFile, ImageFile2, ImageFile3); if (result != 0) { lblMessage.ForeColor = Color.Green; lblMessage.Text = "Product Other Image Added!"; BindBackImg(productid); } } else { lblMessage.ForeColor = Color.Red; lblMessage.Text = "Go View Product & select Product!"; } } catch (Exception ex) { lblMessage.ForeColor = Color.Red; lblMessage.Text = ex.Message; } }