protected string SaveImage() { string strDBImagePath = string.Empty; try { string strServerPath = Server.MapPath(CommonFn.Image_Save_Path); string strSaveImagePath = string.Empty; string fileName = Path.GetFileName(UploadImages.PostedFile.FileName); string FolderName = CommonFn.BannerFolder; if (!CommonFn.folderExists(strServerPath, FolderName)) { try { CommonFn.CreateFolder(strServerPath, FolderName); } catch { } } string strFileNameOnly = CommonFn.GetFileName(fileName); strSaveImagePath = strServerPath + FolderName + "\\" + strFileNameOnly; UploadImages.SaveAs(strSaveImagePath); strDBImagePath = CommonFn.DbSave + CommonFn.DbBannerFolder; strDBImagePath = strDBImagePath + strFileNameOnly; } catch { ; } return(strDBImagePath); }
protected string SaveImage(string UpFileName, int flcontrolId) { string strDBImagePath = string.Empty; try { if (UpFileName.Length < 1035000) { string strServerPath = Server.MapPath(CommonFn.Image_Save_Path); string strSaveImagePath = string.Empty; string fileName = Path.GetFileName(UpFileName); string FileNameWEx = Path.GetFileNameWithoutExtension(fileName); FileNameWEx = objDAEntities.RemoveBadCharForFolder(FileNameWEx); String FileExtension = System.IO.Path.GetExtension(fileName); // listofuploadedfiles.Text = fileName; string FolderName = CommonFn.SeminarGalleryFolder; if (!CommonFn.folderExists(strServerPath, FolderName)) { try { CommonFn.CreateFolder(strServerPath, FolderName); } catch { } } string strFileNameOnly = CommonFn.GetFileName(FileNameWEx); strSaveImagePath = strServerPath + FolderName + "\\" + strFileNameOnly + FileExtension; if (flcontrolId == 1) { UploadImages.SaveAs(strSaveImagePath); } else { FileUploadTOPIC.SaveAs(strSaveImagePath); } strDBImagePath = CommonFn.DbSave + CommonFn.DbSeminarGalleryFolder; strDBImagePath = strDBImagePath + strFileNameOnly; } else { lblMessage.CssClass = "errorlbl"; lblMessage.Text = "Images size is more than 1.035 mb!!!"; ViewState["optype"] = "INSERT"; } } catch { lblMessage.CssClass = "errorlbl"; lblMessage.Text = "Something worng!!!!"; ViewState["optype"] = "INSERT"; } return(strDBImagePath); }
protected string SavePDF() { string strDBPDFPath = string.Empty; try { if (FileUpload2.PostedFile.FileName != null) { string strServerPath = Server.MapPath(CommonFn.Image_Save_Path); string strSavePDFPath = string.Empty; string fileName = Path.GetFileName(FileUpload2.PostedFile.FileName); string FileNameWEx = Path.GetFileNameWithoutExtension(fileName); FileNameWEx = objDAEntities.RemoveBadCharForFolder(FileNameWEx); String FileExtension = System.IO.Path.GetExtension(fileName); if ((FileExtension.ToLower() == ".pdf")) { string FolderName = CommonFn.ResearchPaperPdf; if (!CommonFn.folderExists(strServerPath, FolderName)) { try { CommonFn.CreateFolder(strServerPath, FolderName); } catch { } } strSavePDFPath = strServerPath + FolderName + "\\" + FileNameWEx + FileExtension; if (!File.Exists(strSavePDFPath)) { FileUpload2.SaveAs(strSavePDFPath); } strDBPDFPath = CommonFn.DbSave + CommonFn.DbResearchPaperPDF; strDBPDFPath = strDBPDFPath + FileNameWEx + FileExtension; } } else { ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('pdf size is more than 10.00 mb!!!');", true); } } catch (Exception ex) { throw ex; } return(strDBPDFPath); }
protected string SaveImage() { string strDBImagePath = string.Empty; try { if (UploadImages.PostedFile.FileName != null) { string strServerPath = Server.MapPath(CommonFn.Image_Save_Path); string strSaveImagePath = string.Empty; string fileName = Path.GetFileName(UploadImages.PostedFile.FileName); string FileNameWEx = Path.GetFileNameWithoutExtension(fileName); FileNameWEx = objDAEntities.RemoveBadCharForFolder(FileNameWEx); String FileExtension = System.IO.Path.GetExtension(fileName); //listofuploadedfiles.Text = fileName; if ((FileExtension.ToLower() == ".jpg" || FileExtension.ToLower() == ".png" || FileExtension.ToLower() == ".jpeg" || FileExtension.ToLower() == ".tiff" || FileExtension.ToLower() == ".gif")) { string FolderName = CommonFn.PhotoGalleryFolder; if (!CommonFn.folderExists(strServerPath, FolderName)) { try { CommonFn.CreateFolder(strServerPath, FolderName); } catch { } } //string strFileNameOnly = CommonFn.GetFileName(fileName); strSaveImagePath = strServerPath + FolderName + "\\" + FileNameWEx + FileExtension; UploadImages.SaveAs(strSaveImagePath); strDBImagePath = CommonFn.DbSave + CommonFn.DbPhotoGalleryFolder; strDBImagePath = strDBImagePath + FileNameWEx + FileExtension; } } else { ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Images size is more than 1.035 mb!!!');", true); } } catch (Exception ex) { throw ex; } return(strDBImagePath); }
protected string SaveImage() { string strDBImagePath = string.Empty; try { string strServerPath = Server.MapPath(CommonFn.Image_Save_Path); string strSaveImagePath = string.Empty; string fileName = Path.GetFileName(UploadImages.PostedFile.FileName); String FileExtension = System.IO.Path.GetExtension(fileName); string FolderName = CommonFn.DoctorFolder; if ((FileExtension.ToLower() == ".jpg" || FileExtension.ToLower() == ".png" || FileExtension.ToLower() == ".jpeg" || FileExtension.ToLower() == ".tiff" || FileExtension.ToLower() == ".gif")) { if (!CommonFn.folderExists(strServerPath, FolderName)) { try { CommonFn.CreateFolder(strServerPath, FolderName); } catch { } } string strFileNameOnly = CommonFn.GetFileName(fileName); strSaveImagePath = strServerPath + FolderName + "\\" + strFileNameOnly; UploadImages.SaveAs(strSaveImagePath); strDBImagePath = CommonFn.DbSave + CommonFn.DbDoctorFolder; strDBImagePath = strDBImagePath + strFileNameOnly; } else { ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Only Image file allowed!!!');", true); } } catch { //ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Only Image file allowed!!!');", true); } return(strDBImagePath); }
protected void btnSubmit_Click(object sender, EventArgs e) { try { if (fileUploadWNew.PostedFile.FileName != "") { lblfileName.Text = fileUploadWNew.PostedFile.FileName; if (fileUploadWNew.PostedFile.FileName.Length < 1035000) { string strServerPath = Server.MapPath(CommonFn.Image_Save_Path); string strSaveImagePath = string.Empty; string fileName = Path.GetFileName(lblfileName.Text); string FileNameWEx = Path.GetFileNameWithoutExtension(fileName); string strDBImagePath; FileNameWEx = objDAEntities.RemoveBadCharForFolder(FileNameWEx); String FileExtension = System.IO.Path.GetExtension(fileName); // listofuploadedfiles.Text = fileName; string FolderName = CommonFn.WhatsNewFile; if (!CommonFn.folderExists(strServerPath, FolderName)) { try { CommonFn.CreateFolder(strServerPath, FolderName); } catch { } } string strFileNameOnly = CommonFn.GetFileName(FileNameWEx); strSaveImagePath = strServerPath + FolderName + "\\" + strFileNameOnly + "_" + DateTime.Now.Ticks + FileExtension; fileUploadWNew.SaveAs(strSaveImagePath); objDAEntities.WhatsNewId = 0; //objDAEntities.FileName = strFileNameOnly + FileExtension + "_" + DateTime.Now.Ticks; objDAEntities.WhatsNewTitle = txtWhatsNewTitle.Text; objDAEntities.IsActiveWhatsNew = chkFileActive.Checked; objDAEntities.FilePath = strSaveImagePath; objDAEntities.WNSummury = reWhatsNewSummary.Content.Replace(" ", ""); objDAEntities.UserId = 1; strDBImagePath = CommonFn.DbSave + CommonFn.DbWhatsNew; strDBImagePath = strDBImagePath + strFileNameOnly; objBusinessLogic.AddWhatsNew(objDAEntities); lblMessage.CssClass = "successlbl"; lblMessage.Text = "Data saved successfully!!!"; lblMessage.Visible = true; Clear(); //GetWhatsNew(); } else { lblMessage.CssClass = "errorlbl"; lblMessage.Text = "Images size is more than 1.035 mb!!!"; ViewState["optype"] = "INSERT"; lblMessage.Visible = true; } } } catch (Exception ex) { } }