protected void AjaxFileUpload1_OnUploadComplete(object sender, AjaxFileUploadEventArgs file) { try { Byte[] fileBytes = file.GetContents(); string sPath = Server.MapPath("\\" + System.Configuration.ConfigurationManager.AppSettings["APP_NAME"].ToString() + "\\uploads\\CrewDocuments"); Guid GUID = Guid.NewGuid(); string Flag_Attach = GUID.ToString() + Path.GetExtension(file.FileName); int CrewID = UDFLib.ConvertToInteger(Session["hdnCrewID"].ToString()); int VoyID = UDFLib.ConvertToInteger(Session["hdnVoyID"].ToString()); string FullFilename = Path.Combine(sPath, Flag_Attach); int FileID = objCrewBLL.Insert_CrewAgreementRecord(CrewID, VoyID, 2, 0, "Crew Agreement - Signed by Office", Flag_Attach, Flag_Attach, GetSessionUserID());// objBLL.Insert_Worklist_Attachment(Vessel_ID, Worklist_ID, Office_ID, UDFLib.Remove_Special_Characters(file.FileName), Flag_Attach, file.FileSize, UDFLib.ConvertToInteger(Session["USERID"])); FileStream fileStream = new FileStream(FullFilename, FileMode.Create, FileAccess.ReadWrite); fileStream.Write(fileBytes, 0, fileBytes.Length); fileStream.Close(); } catch (Exception ex) { } }
protected void AjaxFileUpload1_OnUploadComplete(object sender, AjaxFileUploadEventArgs file) { try { Byte[] fileBytes = file.GetContents(); string sPath = Server.MapPath("\\" + System.Configuration.ConfigurationManager.AppSettings["APP_NAME"].ToString() + "\\uploads\\Vetting\\VetRAtt"); Guid GUID = Guid.NewGuid(); string AttachPath = "VET_" + GUID.ToString() + Path.GetExtension(file.FileName); objBLLIndx.VET_Ins_ResponseAttachment(UDFLib.ConvertToInteger(Response_ID), Path.GetFileName(file.FileName), AttachPath, Convert.ToInt32(Session["userid"].ToString())); string FullFilename = Path.Combine(sPath, AttachPath); FileStream fileStream = new FileStream(FullFilename, FileMode.Create, FileAccess.ReadWrite); fileStream.Write(fileBytes, 0, fileBytes.Length); fileStream.Close(); LoadAttachment(ViewState["Response_ID"].ToString()); string jsSqlError2 = "alert('Attachment saved successfully.');"; ScriptManager.RegisterStartupScript(this, this.GetType(), "jsSqlError2", jsSqlError2, true); } catch (Exception ex) { UDFLib.WriteExceptionLog(ex); string js = "alert('" + UDFLib.GetException("SystemError/ GeneralMessage") + "');"; ScriptManager.RegisterStartupScript(this, this.GetType(), "error", js, true); } }
protected void PictureUploader_OnUploadComplete(object sender, AjaxFileUploadEventArgs file) { Session["fileContentType_" + file.FileId] = file.ContentType; Session["fileContents_" + file.FileId] = file.GetContents(); Session["fileName_" + file.FileId] = file.FileName.Split('\\').Last(); string fileName = file.FileName.Split('\\').Last(); string[] fileExtensionToSplit = fileName.Split('.'); string fileExtension = fileExtensionToSplit[fileExtensionToSplit.Length - 1]; fileExtension = fileExtension.ToLower(); if (fileExtension.Contains("mp4") || fileExtension.Contains("mov") || fileExtension.Contains("ogv") || fileExtension.Contains("wmv") || fileExtension.Contains("vlc") || fileExtension.Contains("avi") || fileExtension.Contains("mkv")) { SaveVideo(file); } else if (fileExtension.Contains("jpg") || fileExtension.Contains("gif") || fileExtension.Contains("png") || fileExtension.Contains("jpeg")) { SavePicture(file); } else { SaveFile(file); } }
protected void AjaxFileUpload1_OnUploadComplete(object sender, AjaxFileUploadEventArgs file) { try { BLL_PMS_Library_Jobs objjobs = new BLL_PMS_Library_Jobs(); Byte[] fileBytes = file.GetContents(); string sPath = Server.MapPath("\\" + System.Configuration.ConfigurationManager.AppSettings["APP_NAME"].ToString() + "\\uploads\\PmsJobs"); Guid GUID = Guid.NewGuid(); string AttachPath = "PMS_" + GUID.ToString() + Path.GetExtension(file.FileName); objjobs.LibrarySaveJobInstructionAttachment(Convert.ToInt32(Request.QueryString["VesselCode"].ToString()), Convert.ToInt32(Request.QueryString["JobId"].ToString()), Path.GetFileName(file.FileName), AttachPath , Convert.ToInt32(Session["userid"].ToString()), null); string FullFilename = Path.Combine(sPath, AttachPath); FileStream fileStream = new FileStream(FullFilename, FileMode.Create, FileAccess.ReadWrite); fileStream.Write(fileBytes, 0, fileBytes.Length); fileStream.Close(); } catch (Exception ex) { } }
protected void AjaxFileUpload1_OnUploadComplete(object sender, AjaxFileUploadEventArgs file) { try { Byte[] fileBytes = file.GetContents(); string sPath = Server.MapPath("\\" + System.Configuration.ConfigurationManager.AppSettings["APP_NAME"].ToString() + "\\uploads\\PmsJobs"); Guid GUID = Guid.NewGuid(); string Guid_File_Attach = GUID.ToString() + Path.GetExtension(file.FileName); int FileID = objBLLPurc.INSERT_JOB_DONE_ATTACHMENT(UDFLib.ConvertToInteger(Session["Non_PMS_VESSEL_ID"]), UDFLib.ConvertToInteger(Session["Non_PMS_Job_History_Id"]) , 1, Path.GetFileName(file.FileName), "PMS_" + Guid_File_Attach, file.FileSize, UDFLib.ConvertToInteger(Session["USERID"]), UDFLib.ConvertToInteger(Session["Non_PMS_Office_ID"])); string FullFilename = Path.Combine(sPath, "PMS_" + GUID.ToString() + Path.GetExtension(file.FileName)); FileStream fileStream = new FileStream(FullFilename, FileMode.Create, FileAccess.ReadWrite); fileStream.Write(fileBytes, 0, fileBytes.Length); fileStream.Close(); BindAttachment(); string scrRegGra = "RegisterGralerry();"; ScriptManager.RegisterStartupScript(this, this.GetType(), "scrRegGra", scrRegGra, true); } catch (Exception ex) { } }
protected void fuVideo_OnUploadComplete(object sender, AjaxFileUploadEventArgs file) { // User can save file to File System, database or in session state if (file != null) { string path = Server.MapPath("~/Uploads/VesselVideos"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } Byte[] fileBytes = file.GetContents(); string FileName = Path.GetFileName(file.FileName); Session["OriginalFileName"] = FileName; Guid GUID = Guid.NewGuid(); FileName = "VSLV_" + GUID.ToString() + Path.GetExtension(file.FileName); Session["FileName"] = FileName; int SIZE_BYTES = fileBytes.Length; string FilPath = Path.Combine(Server.MapPath("~/Uploads/VesselVideos/"), FileName); if (File.Exists(FilPath)) { File.Delete(FilPath); } FileStream fileStream = new FileStream(FilPath, FileMode.Create, FileAccess.ReadWrite); fileStream.Write(fileBytes, 0, fileBytes.Length); fileStream.Close(); } }
/// <summary> /// Ajax File Upload /// </summary> protected void AjaxFileUpload1_OnUploadComplete(object sender, AjaxFileUploadEventArgs file) { try { DataTable dta = new DataTable(); dta = objUploadFilesize.Get_Module_FileUpload("PURC_"); BLL_PURC_Purchase objTechService = new BLL_PURC_Purchase(); Byte[] fileBytes = file.GetContents(); string sPath = Server.MapPath("\\" + System.Configuration.ConfigurationManager.AppSettings["APP_NAME"].ToString() + "\\uploads\\Purchase"); Guid GUID = Guid.NewGuid(); string Flag_Attach = GUID.ToString() + Path.GetExtension(file.FileName); int sts = objTechService.SaveAttachedFileInfo_New(Convert.ToString(VesselCode), DocCode, "0", Path.GetExtension(file.FileName), UDFLib.Remove_Special_Characters(Path.GetFileName(file.FileName)), "../Uploads/Purchase/" + Flag_Attach, Session["USERID"].ToString(), 0); string FullFilename = Path.Combine(sPath, GUID.ToString() + Path.GetExtension(file.FileName)); FileStream fileStream = new FileStream(FullFilename, FileMode.Create, FileAccess.ReadWrite); fileStream.Write(fileBytes, 0, fileBytes.Length); fileStream.Close(); } catch (Exception ex) { UDFLib.WriteExceptionLog(ex); } } //-- Attachment Upload
protected void AjaxFileUpload1_OnUploadComplete(object sender, AjaxFileUploadEventArgs file) { try { BLL_Tec_Inspection objTechService = new BLL_Tec_Inspection(); Byte[] fileBytes = file.GetContents(); string sPath = Server.MapPath("\\" + System.Configuration.ConfigurationManager.AppSettings["APP_NAME"].ToString() + "\\uploads\\Technical"); Guid GUID = Guid.NewGuid(); string Flag_Attach = GUID.ToString() + Path.GetExtension(file.FileName); string FullFilename = Path.Combine(sPath, GUID.ToString() + Path.GetExtension(file.FileName)); int sts = objTechService.SaveAttachedFileInfo(Request.QueryString["VESSEL_ID"].ToString(), Request.QueryString["InspectionDetailId"].ToString(), Path.GetFileName(file.FileName), UDFLib.Remove_Special_Characters(Path.GetFileName(FullFilename)), Session["USERID"].ToString()); FileStream fileStream = new FileStream(FullFilename, FileMode.Create, FileAccess.ReadWrite); fileStream.Write(fileBytes, 0, fileBytes.Length); fileStream.Close(); // ScriptManager.RegisterStartupScript(this, typeof(Page), "refresh", "fn_OnClose(a,b)", true); } catch (Exception ex) { } }
protected void AjaxFileUpload1_OnUploadComplete(object sender, AjaxFileUploadEventArgs file) { // User can save file to File System, database or in session state if (file.ContentType.Contains("jpg") || file.ContentType.Contains("gif") || file.ContentType.Contains("png") || file.ContentType.Contains("jpeg")) { // Limit preview file for file equal or under 4MB only, otherwise when GetContents invoked // System.OutOfMemoryException will thrown if file is too big to be read. if (file.FileSize <= 1024 * 1024 * 4) { Session["fileContentType_" + file.FileId] = file.ContentType; Session["fileContents_" + file.FileId] = file.GetContents(); // Set PostedUrl to preview the uploaded file. file.PostedUrl = string.Format("?preview=1&fileId={0}", file.FileId); } else { file.PostedUrl = "fileTooBig.gif"; } // Since we never call the SaveAs method(), we need to delete the temporary fileß file.DeleteTemporaryData(); } // In a real app, you would call SaveAs() to save the uploaded file somewhere // AjaxFileUpload1.SaveAs(MapPath("~/App_Data/" + file.FileName), true); }
protected void AjaxFileUpload1_OnUploadComplete(object sender, AjaxFileUploadEventArgs file) { Session["fileContentType_" + file.FileId] = file.ContentType; Session["fileContents_" + file.FileId] = file.GetContents(); Session["fileName_" + file.FileId] = file.FileName.Split('\\').Last(); file.PostedUrl = string.Format("?preview=1&fileId={0}", file.FileId); }
/// <summary> /// Modified By Anjali DT:14-10-2016 /// To save attached files to DB. /// </summary> /// <param name="sender"></param> /// <param name="file"></param> protected void AjaxFileUpload1_OnUploadComplete(object sender, AjaxFileUploadEventArgs file) { try { dtattachment = (DataTable)Session["Attachment"]; Byte[] fileBytes = file.GetContents(); string sPath = Server.MapPath("\\" + System.Configuration.ConfigurationManager.AppSettings["APP_NAME"].ToString() + "\\uploads\\Technical"); string sPath1 = Server.MapPath("\\" + System.Configuration.ConfigurationManager.AppSettings["APP_NAME"].ToString() + "\\uploads\\Inspection"); Guid GUID = Guid.NewGuid(); string _fileName = ""; string Flag_Attach = GUID.ToString() + Path.GetExtension(file.FileName); int Vessel_ID = Convert.ToInt32(Request.QueryString["VesselID"].ToString()); /* Here it should be received after inserting data TEC_WORKLIST_MAIN*/ int Worklist_ID = Convert.ToInt32(Session["WID"]); /* Here it should be received after inserting data TEC_WORKLIST_MAIN*/ int Office_ID = Convert.ToInt32(Session["OID"]); /* Here it should be received after inserting data TEC_WORKLIST_MAIN*/ int FileID = objInsp.Insert_Worklist_Attachment(Vessel_ID, Worklist_ID, Office_ID, UDFLib.Remove_Special_Characters(Path.GetFileName(file.FileName)), Flag_Attach, file.FileSize, UDFLib.ConvertToInteger(Session["USERID"])); _fileName = "TEC_" + Vessel_ID + "_" + Worklist_ID + "_" + Office_ID + "_" + "O" + "_" + FileID.ToString() + "_" + Flag_Attach; if (FileID > 0) { int Ret = objInsp.Insert_ActivityObject(Vessel_ID, Worklist_ID, Office_ID, UDFLib.Remove_Special_Characters(Path.GetFileName(file.FileName)), /* filattachPath, */ _fileName, UDFLib.ConvertToInteger(Session["USERID"])); string FullFilename = Path.Combine(sPath, _fileName); //Save attached file to folder FileStream fileStream = new FileStream(FullFilename, FileMode.Create, FileAccess.ReadWrite); fileStream.Write(fileBytes, 0, fileBytes.Length); fileStream.Close(); File.Copy(FullFilename, Path.Combine(sPath1, _fileName)); Load_Attachments(Vessel_ID, Worklist_ID, Office_ID, UDFLib.ConvertToInteger(Session["USERID"])); string jsPopClose = " hideModal('dvPopupAddAttachment');"; ScriptManager.RegisterStartupScript(this, this.GetType(), "jsPopClose", jsPopClose, true); } else { string jsPopAlert = " alert('File Already exists.');"; ScriptManager.RegisterStartupScript(AjaxFileUpload1, AjaxFileUpload1.GetType(), "jsPopAlert", jsPopAlert, true); } } catch (Exception ex) { UDFLib.WriteExceptionLog(ex); } }
protected void AjaxFileUpload1_OnUploadComplete(object sender, AjaxFileUploadEventArgs file) { try { Session["vsAttachmentData"] = file.GetContents(); Session["vsAttachmentFileName"] = file.FileName; } catch (Exception ex) { } }
protected void DetailsImageUploader_OnUploadComplete(object sender, AjaxFileUploadEventArgs file) { try { Session["DetailsImage"] = file.GetContents(); Session["ItemOperationMode"] = hdnItemOperationMode; } catch (Exception ex) { } }
protected void AjaxFileUpload1_OnUploadComplete(object sender, AjaxFileUploadEventArgs file) { // User can save file to File System, database or in session state if (file.ContentType.Contains("xls") || file.ContentType.Contains("xlsx")) { Session["fileContentType_" + file.FileId] = file.ContentType; Session["fileContents_" + file.FileId] = file.GetContents(); } // Set PostedUrl to preview the uploaded file. file.PostedUrl = string.Format("?preview=1&fileId={0}", file.FileId); }
protected void AjaxFileUploadInsertImage_OnUploadComplete(object sender, AjaxFileUploadEventArgs file) { Byte[] fileBytes = file.GetContents(); string sPath = Server.MapPath("\\" + System.Configuration.ConfigurationManager.AppSettings["APP_NAME"].ToString() + "\\uploads\\QMSDB"); Guid GUID = Guid.NewGuid(); string FullFilename = Path.Combine(sPath, "QMSDB_" + GUID.ToString() + Path.GetExtension(file.FileName)); FileStream fileStream = new FileStream(FullFilename, FileMode.Create, FileAccess.ReadWrite); fileStream.Write(fileBytes, 0, fileBytes.Length); fileStream.Close(); txtProcedureSectionDetails.Text = txtProcedureSectionDetails.Text + "<img src=\"" + FullFilename + "\" />"; }
protected void AjaxFileUploadInsertImage_OnUploadComplete(object sender, AjaxFileUploadEventArgs file) { Byte[] fileBytes = file.GetContents(); string sPath = Server.MapPath("/" + ConfigurationManager.AppSettings["QMSDBPath"] + "/"); string FileName = "QMSDB_" + Guid.NewGuid().ToString() + Path.GetExtension(file.FileName); string FullFilename = Path.Combine(sPath, FileName); FileStream fileStream = new FileStream(FullFilename, FileMode.Create, FileAccess.ReadWrite); fileStream.Write(fileBytes, 0, fileBytes.Length); fileStream.Close(); BLL_QMSDB_ProcedureSection.Ins_Procedure_Attachment(Convert.ToInt32(Request.QueryString["PROCEDURE_ID"]), FileName, Convert.ToInt32(Session["userid"])); Session["UploadedFiles_Name"] += FileName + ","; }
protected void AjaxFileUpload1_OnUploadComplete(object sender, AjaxFileUploadEventArgs file) { // User can save file to File System, database or in session state Dictionary <string, Byte[]> Files = new Dictionary <string, byte[]>(); if (file != null) { if (Session["MedicalCostItemAttachments"] != null) { Files = Session["MedicalCostItemAttachments"] as Dictionary <string, Byte[]>; } Files.Add(file.FileName, file.GetContents()); Session["MedicalCostItemAttachments"] = Files; } }
protected void AjaxFileUpload1_OnUploadComplete(object sender, AjaxFileUploadEventArgs file) { try { Byte[] fileBytes = file.GetContents(); string sPath = System.Configuration.ConfigurationManager.AppSettings["OCA_Folder_NAME"].ToString(); // string sPath = Server.MapPath("\\" + System.Configuration.ConfigurationManager.AppSettings["APP_NAME"].ToString() + "\\uploads\\Infobase"); Guid GUID = Guid.NewGuid(); string Flag_Attach = GUID.ToString() + Path.GetExtension(file.FileName); string FullFilename = Path.Combine(sPath, GUID.ToString() + Path.GetExtension(file.FileName)); FileStream fileStream = new FileStream(FullFilename, FileMode.Create, FileAccess.ReadWrite); fileStream.Write(fileBytes, 0, fileBytes.Length); fileStream.Close(); Session["Filename"] = Flag_Attach; Session["extension"] = Path.GetExtension(file.FileName); Session["OriginalFile"] = Path.GetFileName(file.FileName); //FileInfo fi = new FileInfo(sPath+"\\" + Session["Filename"]); //double size = fi.Length; //string folderid = ddlDepartment.SelectedValue; //string fun = null; //DataTable dt = objCP.Insert_UploadFiles(Session["OriginalFile"].ToString(), Session["extension"].ToString().Replace(".", ""), size, Convert.ToInt32(GetSessionUserID()), folderid, txtTitle.Text, txtContent.Text, Session["Charter_ID"].ToString(), "ADD", fun); //string res = dt.Rows[0]["File_Id"].ToString(); //Session["res"]=res; //string F1 = Mid(res, 0, 2); //string F2 = Mid(res, 2, 2); //string F3 = Mid(res, 4, 2); //if (!Directory.Exists(sPath+"\\" + F1 + "\\" + F2 + "\\" + F3)) //{ // Directory.CreateDirectory(sPath + "\\" + F1 + "\\" + F2 + "\\" + F3); //} // File.Move(sPath+"\\" + Session["Filename"], Path.Combine(sPath + "\\" + F1 + "\\" + F2 + "\\" + F3, GUID.ToString() + Path.GetExtension(file.FileName))); //UploadFile(sPath + "\\" + F1 + "\\" + F2 + "\\" + F3 + "\\" + Session["Filename"]); UploadFile(sPath + "\\" + Session["Filename"]); } catch (Exception ex) { } }
/// <summary> /// To save attached files to DB. /// </summary> /// <param name="sender"></param> /// <param name="file"></param> protected void AjaxFileUpload1_OnUploadComplete(object sender, AjaxFileUploadEventArgs file) { try { Byte[] fileBytes = file.GetContents(); string sPath = Server.MapPath("\\" + System.Configuration.ConfigurationManager.AppSettings["APP_NAME"].ToString() + "\\uploads\\Technical"); string sPath1 = Server.MapPath("\\" + System.Configuration.ConfigurationManager.AppSettings["APP_NAME"].ToString() + "\\uploads\\Inspection"); Guid GUID = Guid.NewGuid(); string Flag_Attach = GUID.ToString() + Path.GetExtension(file.FileName); int Office_ID = Convert.ToInt32(Request.QueryString["OFFID"]); int Worklist_ID = Convert.ToInt32(Request.QueryString["WLID"]); int Vessel_ID = Convert.ToInt32(Request.QueryString["VID"]); string _fileName = ""; int FileID = objBLL.Insert_Worklist_Attachment(Vessel_ID, Worklist_ID, Office_ID, UDFLib.Remove_Special_Characters(file.FileName), Flag_Attach, file.FileSize, UDFLib.ConvertToInteger(Session["USERID"])); _fileName = "TEC_" + Vessel_ID + "_" + Worklist_ID + "_" + Office_ID + "_" + "O" + "_" + FileID.ToString() + "_" + Flag_Attach; // This method insert attachments in object table and it will sync to mobile by Pranav Sakpal on 2016-03-23 int Ret = objBLL.Insert_ActivityObject(Vessel_ID, Worklist_ID, Office_ID, _fileName, _fileName, UDFLib.ConvertToInteger(Session["USERID"])); string FullFilename = Path.Combine(sPath, _fileName); //Save attached file to folder FileStream fileStream = new FileStream(FullFilename, FileMode.Create, FileAccess.ReadWrite); fileStream.Write(fileBytes, 0, fileBytes.Length); fileStream.Close(); // This will copy attachments in inspection folder it will sync to mobile by Pranav Sakpal on 2016-03-23 string filecopyname = _fileName; File.Copy(FullFilename, Path.Combine(sPath1, filecopyname), true); Load_Attachments(Vessel_ID, Worklist_ID, Office_ID, GetSessionUserID()); } catch (Exception ex) { UDFLib.WriteExceptionLog(ex); } }
protected void SaveVideo(AjaxFileUploadEventArgs file) { byte[] videoBytes = file.GetContents(); string fileName = file.FileName.Split('\\').Last(); Video_Post videoPost = new Video_Post(); Group g = new Group(); PostDAL postDAl = new PostDAL(); aMember.MemberId = (string)Session["memberID"]; g.GroupId = int.Parse(ThisGroupsID.Value); videoPost.Video = videoBytes; videoPost.VideoName = fileName; videoPost.VideoSize = file.FileSize; videoPost.VideoCaption = captionP; postDAl.InsertVideo(videoPost, g, aMember); }
protected void AjaxFileUpload1_OnUploadComplete(object sender, AjaxFileUploadEventArgs file) { // User can save file to File System, database or in session state Byte[] fileBytes = file.GetContents(); string sPath = Server.MapPath("\\" + System.Configuration.ConfigurationManager.AppSettings["APP_NAME"].ToString() + "\\uploads\\Allotments"); Guid GUID = Guid.NewGuid(); string FullFilename = Path.Combine(sPath, GUID.ToString() + Path.GetExtension(file.FileName)); string Flag_Attach = GUID.ToString() + Path.GetExtension(file.FileName); FileStream fileStream = new FileStream(FullFilename, FileMode.Create, FileAccess.ReadWrite); fileStream.Write(fileBytes, 0, fileBytes.Length); fileStream.Close(); DataTable dtattach = (DataTable)Session["dtFlagFiles"]; if (dtattach.Rows.Count > 0) { DataRow drAttch = dtattach.NewRow(); int pkid = Convert.ToInt32((dtattach.Rows[dtattach.Rows.Count - 1]["PKID"])) + 1; drAttch["Flag_Attach_Name"] = file.FileName; drAttch["Flag_Attach"] = "uploads/Allotments/" + Flag_Attach; drAttch["PKID"] = pkid; dtattach.Rows.Add(drAttch); Session["dtFlagFiles"] = dtattach; } else { DataRow drAttch = dtattach.NewRow(); drAttch["Flag_Attach_Name"] = file.FileName; drAttch["Flag_Attach"] = "uploads/Allotments/" + Flag_Attach; drAttch["PKID"] = 1; dtattach.Rows.Add(drAttch); Session["dtFlagFiles"] = dtattach; } }
protected void SaveFile(AjaxFileUploadEventArgs file) { byte[] fileBytes = file.GetContents(); string fileName = file.FileName.Split('\\').Last(); File_Post filePost = new File_Post(); Group g = new Group(); PostDAL postDAl = new PostDAL(); aMember.MemberId = (string)Session["memberID"]; g.GroupId = int.Parse(ThisGroupsID.Value); filePost.File = fileBytes; filePost.FileName = fileName; filePost.FileSize = file.FileSize; filePost.FileCaption = captionP; postDAl.InsertFile(filePost, g, aMember); }
/// <summary> /// Ajax File Upload save as Guid and store file info in sessions /// </summary> /// <param name="sender"></param> /// <param name="file"></param> protected void AjaxFileUpload1_OnUploadComplete(object sender, AjaxFileUploadEventArgs file) { try { Byte[] fileBytes = file.GetContents(); string sPath = Server.MapPath("\\" + System.Configuration.ConfigurationManager.AppSettings["APP_NAME"].ToString() + "\\uploads\\Infobase"); Guid GUID = Guid.NewGuid(); string Flag_Attach = GUID.ToString() + Path.GetExtension(file.FileName); string FullFilename = Path.Combine(sPath, GUID.ToString() + Path.GetExtension(file.FileName)); FileStream fileStream = new FileStream(FullFilename, FileMode.Create, FileAccess.ReadWrite); fileStream.Write(fileBytes, 0, fileBytes.Length); fileStream.Close(); Session["Filename"] = Flag_Attach; Session["extension"] = Path.GetExtension(file.FileName); Session["OriginalFile"] = Path.GetFileName(file.FileName); Label1.Visible = false; } catch (Exception ex) { } }
protected void AjaxFileUpload1_OnUploadComplete(object sender, AjaxFileUploadEventArgs file) { try { BLL_PURC_Purchase objTechService = new BLL_PURC_Purchase(); Byte[] fileBytes = file.GetContents(); string sPath = Server.MapPath("\\" + System.Configuration.ConfigurationManager.AppSettings["APP_NAME"].ToString() + "\\uploads\\Purchase"); Guid GUID = Guid.NewGuid(); string Flag_Attach = GUID.ToString() + Path.GetExtension(file.FileName); int sts = objTechService.SaveAttachedFileInfo(Request.QueryString["AttVesselCode"].ToString(), Session["AttRequistionCode"].ToString(), "0", Path.GetExtension(file.FileName), UDFLib.Remove_Special_Characters(file.FileName), "../Uploads/Purchase/" + Flag_Attach, Session["USERID"].ToString(), 0); string FullFilename = Path.Combine(sPath, GUID.ToString() + Path.GetExtension(file.FileName)); FileStream fileStream = new FileStream(FullFilename, FileMode.Create, FileAccess.ReadWrite); fileStream.Write(fileBytes, 0, fileBytes.Length); fileStream.Close(); } catch (Exception ex) { } }
protected void AjaxFileUpload1_OnUploadComplete(object sender, AjaxFileUploadEventArgs file) { try { BLL_PURC_Purchase objTechService = new BLL_PURC_Purchase(); Byte[] fileBytes = file.GetContents(); string SavePath = Server.MapPath("\\" + System.Configuration.ConfigurationManager.AppSettings["APP_NAME"].ToString() + "\\Uploads\\Files_Uploaded"); Guid GUID = Guid.NewGuid(); string Flag_Attach = GUID.ToString() + Path.GetExtension(file.FileName); string FileID = BLL_POLOG_Register.POLOG_Insert_AttachedFile(UDFLib.ConvertStringToNull(Request.QueryString["ID"].ToString()), Path.GetExtension(file.FileName), UDFLib.Remove_Special_Characters(Path.GetFileName(file.FileName)), Flag_Attach, Request.QueryString["DocType"].ToString(), Convert.ToInt16(GetSessionUserID())); FileID = FileID.PadLeft(8, '0'); string F1 = Mid(FileID, 0, 2); string F2 = Mid(FileID, 2, 2); string F3 = Mid(FileID, 4, 2); if (!Directory.Exists(SavePath + F1 + "\\" + F2 + "\\" + F3)) { Directory.CreateDirectory(SavePath + F1 + "\\" + F2 + "\\" + F3); } string FullFilename = Path.Combine(SavePath + "\\" + F1 + "\\" + F2 + "\\" + F3, FileID.ToString() + Path.GetExtension(file.FileName)); //string FullFilename = Path.Combine(sPath, GUID.ToString() + Path.GetExtension(file.FileName)); FileStream fileStream = new FileStream(FullFilename, FileMode.Create, FileAccess.ReadWrite); fileStream.Write(fileBytes, 0, fileBytes.Length); fileStream.Close(); ScriptManager.RegisterStartupScript(this, typeof(Page), "refresh", "fn_OnClose(a,b)", true); } catch (Exception ex) { } }
protected void SavePicture(AjaxFileUploadEventArgs file) { byte[] imageBytes = file.GetContents(); string fileName = file.FileName.Split('\\').Last(); MemoryStream ms = new MemoryStream(imageBytes, 0, imageBytes.Length); // Convert byte[] to Image ms.Write(imageBytes, 0, imageBytes.Length); System.Drawing.Image image = System.Drawing.Image.FromStream(ms, true); Photo_Post photoPost = new Photo_Post(); Group g = new Group(); PostDAL postDAl = new PostDAL(); aMember.MemberId = (string)Session["memberID"]; g.GroupId = int.Parse(ThisGroupsID.Value); photoPost.Photo = image; photoPost.PhotoName = fileName; photoPost.PhotoCaption = captionP; postDAl.InsertPhoto(photoPost, g, aMember); }
protected void AjaxFileUpload1_OnUploadComplete(object sender, AjaxFileUploadEventArgs file) { try { int CrewID = GetCrewID(); int UserID = GetSessionUserID(); Byte[] fileBytes = file.GetContents(); string sPath = Server.MapPath("\\" + System.Configuration.ConfigurationManager.AppSettings["APP_NAME"].ToString() + "\\uploads\\CrewDocuments"); Guid GUID = Guid.NewGuid(); string Flag_Attach = GUID.ToString() + Path.GetExtension(file.FileName); int sts = objBLLCrew.Insert_Crew_MatrixAttachment(CrewID, Path.GetFileName(file.FileName), Flag_Attach, UserID); string FullFilename = Path.Combine(sPath, GUID.ToString() + Path.GetExtension(file.FileName)); FileStream fileStream = new FileStream(FullFilename, FileMode.Create, FileAccess.ReadWrite); fileStream.Write(fileBytes, 0, fileBytes.Length); fileStream.Close(); } catch (Exception ex) { } }
protected void AjaxFileUpload1_OnUploadComplete(object sender, AjaxFileUploadEventArgs file) { // User can save file to File System, database or in session state Dictionary <string, Byte[]> Files = new Dictionary <string, byte[]>(); if (file != null) { Byte[] fileBytes = file.GetContents(); string FileName = file.FileName; int SIZE_BYTES = fileBytes.Length; Guid GUID = Guid.NewGuid(); string FilPath = Path.Combine(Server.MapPath("~/Uploads/CrewRewardDocument/"), GUID.ToString() + Path.GetExtension(FileName)); string Attach_Name = Path.GetFileName(FileName); string Attach_Path = GUID.ToString() + Path.GetExtension(FileName); FileStream fileStream = new FileStream(FilPath, FileMode.Create, FileAccess.ReadWrite); fileStream.Write(fileBytes, 0, fileBytes.Length); fileStream.Close(); Session["FileName"] = Attach_Name; Session["FilPath"] = Attach_Path; } }
protected void OnUploadComplete(object sender, AjaxFileUploadEventArgs e) { byte[] profilePicture = e.GetContents(); this.UsersServices.Upload(this.CurrentUser.Id, profilePicture); }
protected void AjaxFileUpload1_OnUploadComplete(object sender, AjaxFileUploadEventArgs file) { try { DataTable dt = new DataTable(); dt = objUploadFilesize.Get_Module_FileUpload("PURC_"); Byte[] fileBytes = file.GetContents(); string sPath = Server.MapPath("\\" + System.Configuration.ConfigurationManager.AppSettings["APP_NAME"].ToString() + "\\uploads\\PURC_Items"); Guid GUID = Guid.NewGuid(); if (Session["ItemID"] != null) { if (dt.Rows.Count > 0) { string datasize = dt.Rows[0]["Size_KB"].ToString(); if (fileBytes.Length < Int32.Parse(dt.Rows[0]["Size_KB"].ToString()) * 1024) { string Flag_Attach = "itm_" + GUID.ToString() + Path.GetExtension(file.FileName); string FullFilename = Path.Combine(sPath, "itm_" + GUID.ToString() + Path.GetExtension(file.FileName)); StringBuilder insetItem = new StringBuilder(); if (Session["ImageType"] != null) { if (Session["ImageType"].ToString() == "Image") { hdnImageURL.Value = Flag_Attach.ToString(); } else { hdnProductURL.Value = Flag_Attach.ToString(); } } else { hdnImageURL.Value = Flag_Attach.ToString(); } int val = BLL_PURC_Common.ItemImageUpdate(Convert.ToInt32(GetSessionUserID()), Session["ItemID"].ToString(), Convert.ToString(GetCatalogue()), Convert.ToString(GetSubCatalogue()), hdnImageURL.Value, hdnProductURL.Value); FileStream fileStream = new FileStream(FullFilename, FileMode.Create, FileAccess.ReadWrite); fileStream.Write(fileBytes, 0, fileBytes.Length); fileStream.Close(); // Session["AppAttach_" + Request.QueryString["ItemID"].ToString()] = Flag_Attach + "," + file.FileName; } else { string message = "alert('KB File size exceeds maximum limit.')"; ScriptManager.RegisterClientScriptBlock((sender as Control), this.GetType(), "alert", message, true); } } else { string message = "alert('Upload size not set!')"; ScriptManager.RegisterClientScriptBlock((sender as Control), this.GetType(), "alert", message, true); } } else { string message = "alert('Please First Save Item!')"; ScriptManager.RegisterClientScriptBlock((sender as Control), this.GetType(), "alert", message, true); } } catch (Exception ex) { UDFLib.WriteExceptionLog(ex); } }