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) { // 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 e) { _proId = Convert.ToInt32(Request.QueryString["projId"]); var filePath = _proId + "," + Path.GetFileName(e.FileName); var fileName = Page.Server.MapPath("~/Uploads/ProjectDocs/" + filePath); //AjaxFileUpload1.SaveAs(fileName); var fileByte = new byte[] {}; //using (FileStream fs = File.OpenRead(filePath)) //{ // fileByte = _imageService.ReadToEnd(e.); //} var upload = new ProjectDocument { name = filePath, proj_id = _proId, doc_type = e.ContentType, file = fileByte, created_at = DateTime.Now, modified_at = DateTime.Now, location = fileName }; _projectService.SaveProjectDocuments(upload); // ReadFile(filePath); }
protected void AjaxFileUpload1_OnUploadComplete(object sender, AjaxFileUploadEventArgs e) { var filename = Page.Server.MapPath("~/Uploads/ProjectDocs/" + Path.GetFileName(e.FileName)); // Proposal Document AjaxFileUpload1.SaveAs(filename); }
protected void HtmlEditorExtender2_ImageUploadComplete(object sender, AjaxFileUploadEventArgs e) { var ajaxFileupload = (AjaxFileUpload)sender; ajaxFileupload.SaveAs(Server.MapPath("~/photo-evidence/") + e.FileName); e.PostedUrl = Page.ResolveClientUrl("../photo-evidence/" + e.FileName); }
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); } }
/// <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 { 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 { 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 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(); } }
protected void File_Upload(object sender, AjaxFileUploadEventArgs e) { string filename = e.FileName; int userID = 1; // Foreign key to Table Users.. int albumID = 10; // Foreign key to Table Albums.. string username = "******"; // USE Context.User.Identity.Name for authenticated users.. try { // Resize image before upload | Create thumbnail for previews.. Stream fileStream = e.GetStreamContents(); ImageResizer imRes = new ImageResizer(307200, fileStream, Path.GetExtension(filename)); byte[] imageThumbnail; byte[] scaledUploadFile = imRes.ScaleImageFromStream(out imageThumbnail, 200, 200); // Generate a Guid for public file name.. Guid guid = Guid.NewGuid(); AzurePhotoClient blobClient = new AzurePhotoClient("azurephotos"); blobClient.UploadFromBytes(scaledUploadFile, "hq/" + username + "/album/" + albumID + "/" + guid + Path.GetExtension(filename)); blobClient.UploadFromBytes(imageThumbnail, "thumbnail/" + username + "/album/" + albumID + "/" + guid + Path.GetExtension(filename)); // Log photo to DB.. DbAccess dbAccess = new DbAccess(); dbAccess.InsertPhotoToDb(userID, filename, guid, scaledUploadFile.Length, albumID); e.DeleteTemporaryData(); } catch (Exception ex) { // Log error.. } }
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 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 File_Upload(object sender, AjaxFileUploadEventArgs e) { string filename = e.FileName; string strDestPath = Server.MapPath("Input/"); AjaxFileUpload1.SaveAs(@strDestPath + filename); }
protected void Save(object sender, AjaxFileUploadEventArgs e) { string fullPath = Path.Combine(Server.MapPath("~/" + Folder + "/"), e.FileName); fileupload.SaveAs(fullPath); SaveCompleted?.Invoke(null, fullPath); }
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); }
protected void AjaxFileUpload1_OnUploadComplete(object sender, AjaxFileUploadEventArgs e) { var id = _id; var filename = Page.Server.MapPath("~/Uploads/CVS/" + Path.GetFileName(e.FileName)); //CV AjaxFileUpload1.SaveAs(filename); }
protected void HtmlEditorExtender1_ImageUploadComplete(object sender, AjaxFileUploadEventArgs e) { string fullpath = Server.MapPath("~/ImagesArticle/") + e.FileName; var ajaxFileUpload = (AjaxFileUpload)sender; //HtmlEditorExtender1.AjaxFileUpload.SaveAs(fullpath); ajaxFileUpload.SaveAs(fullpath); e.PostedUrl = Page.ResolveUrl("~/ImagesArticle/" + e.FileName); }
/// <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 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) { try { Session["vsAttachmentData"] = file.GetContents(); Session["vsAttachmentFileName"] = file.FileName; } 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 MyHtmlEditorExtender_ImageUploadComplete(object sender, AjaxFileUploadEventArgs e) { // Generate file path string filePath = "~/Images/" + e.FileName; // Save uploaded file to the file system var ajaxFileUpload = (AjaxFileUpload)sender; ajaxFileUpload.SaveAs(MapPath(filePath)); // Update client with saved image path e.PostedUrl = Page.ResolveUrl(filePath); }
protected void Save(object sender, AjaxFileUploadEventArgs e) { string id = Session["itemId"].ToString(); string filename = $"{id}{Path.GetExtension(e.FileName)}"; fileupload.SaveAs(Path.Combine(Server.MapPath("~/UploadedFiles/"), filename)); if (!LoadedList.ContainsKey(id)) { LoadedList.Add(id, true); } LoadRpt(); }
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; } }
public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer) { var args = new AjaxFileUploadEventArgs ( serializer.ConvertItemToTypeOrDefault <string>(dictionary, "FileId"), serializer.ConvertItemToTypeOrDefault <AjaxFileUploadState>(dictionary, "State"), serializer.ConvertItemToTypeOrDefault <string>(dictionary, "StatusMessage"), serializer.ConvertItemToTypeOrDefault <string>(dictionary, "FileName"), serializer.ConvertItemToTypeOrDefault <int>(dictionary, "FileSize"), serializer.ConvertItemToTypeOrDefault <string>(dictionary, "ContentType") ) { PostedUrl = serializer.ConvertItemToTypeOrDefault <string>(dictionary, "PostedUrl") }; return(args); }
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); } }