protected void fileUploadComplete(object sender, AsyncFileUploadEventArgs e) { if (fileUpload1.HasFile && IsValidPhoto(Convert.ToInt32(fileUpload1.PostedFile.ContentLength)))//Checks Valid Photo Type or not { Thread.Sleep(1000); string newfilenameWithExt = ""; string ext = System.IO.Path.GetExtension(fileUpload1.FileName); Bitmap bmpImg = null; newfilenameWithExt = hdnFileNmWithoutExt.Value + ext;//hidden field value is set on Page load if (hdnOldFileName.Value != "")//Old Picture is removed { string oldFilePath = Server.MapPath("~/") + "/storedata/" + "studentphotos/" + hdnOldFileName.Value; FileInfo oldFile = new FileInfo(oldFilePath); if (System.IO.File.Exists(oldFilePath)) System.IO.File.Delete(oldFilePath); } // Resize Image Before Uploading to Storedata bmpImg = Resize_Image(fileUpload1.PostedFile.InputStream, 97, 120); bmpImg.Save(Server.MapPath("~/") + "/storedata/" + "studentphotos/" + newfilenameWithExt, ImageFormat.Jpeg); Session["ProfileImg"] = newfilenameWithExt; loadStudentProfilePicture();//method to load studentprofilepicture HttpResponse.RemoveOutputCacheItem("/personalDetails.aspx"); StudentApplication objStdFileUpload = new StudentApplication(); objStdFileUpload.StudentFormID = 0; if (Session["FormId"] != DBNull.Value && Session["FormId"].ToString() != "") objStdFileUpload.StudentFormID = Convert.ToInt32(Session["FormId"].ToString()); objStdFileUpload.StudentProfileImage = newfilenameWithExt; if (objStdFileUpload.StudentFormID != 0) objStdFileUpload.UpdateFileNameUploadByFormID(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)