void AsyncFileUpload1_UploadedComplete(object sender, AsyncFileUploadEventArgs e) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "size", "top.$get(\"" + uploadResult.ClientID + "\").innerHTML = 'Uploaded size: " + AsyncFileUpload1.FileBytes.Length.ToString() + "';", true); //Uncomment to save to AsyncFileUpload\Uploads folder. //ASP.NET must have the necessary permissions to write to the file system. string savePath = MapPath("~/Dashboard/Uploads/" + Path.GetFileName(e.FileName)); AsyncFileUpload1.SaveAs(savePath); }
void AsyncFileUpload_UploadedComplete(object sender, AsyncFileUploadEventArgs e) { try { string path = ""; string urlFile = ""; SqlFunction sqlFun = new SqlFunction(HttpContext.Current.Session.GetConnectionString2()); string duongdanfilecu = sqlFun.GetOneStringField(@"select top 1 duongDanFile from dbo.tblNghiemThu WHERE sttNghiemThupr='" + hdfSttNT.Value.ToString() + "'"); //lấy mã dự án string sttDuAnpr = sqlFun.GetOneStringField("select top 1 CONVERT(NVARCHAR(50),sttDuAnpr_sd) from tblNghiemThu where sttNghiemThupr='" + hdfSttNT.Value.ToString() + "'"); string tenFile = e.filename;//"VanBan" + hdfSTTVanBan.Value + ".pdf"; if (!System.IO.Directory.Exists(Server.MapPath("~/VanBan/" + HttpContext.Current.Session.GetDonVi().maDonVi + "/" + sttDuAnpr + "/nghiemThu"))) { System.IO.Directory.CreateDirectory(Server.MapPath("~/VanBan/" + HttpContext.Current.Session.GetDonVi().maDonVi + "/" + sttDuAnpr + "/nghiemThu")); } string strDate = DateTime.Now.ToString("dd_MM_yy_hhmmss"); string fileExtension = Path.GetExtension(tenFile).Replace("-", ""); tenFile = tenFile.Substring(tenFile.LastIndexOf("\\\\") + 1); tenFile = tenFile.Substring(0, tenFile.LastIndexOf(fileExtension)) + strDate + fileExtension; tenFile = tenFile.Replace(" ", ""); //path = string.Concat(Server.MapPath("/VanBan/" + HttpContext.Current.Session.GetDonVi().maDonVi + "/KHoachDThau/")); path = string.Concat(Server.MapPath("/VanBan/" + HttpContext.Current.Session.GetDonVi().maDonVi + "/" + sttDuAnpr + "/nghiemThu/" + tenFile + "")); if (!System.IO.File.Exists(path)) { //save lại file mới AsyncFileUpload.SaveAs(path); urlFile = "/VanBan/" + HttpContext.Current.Session.GetDonVi().maDonVi + "/" + sttDuAnpr + "/nghiemThu/" + tenFile + ""; sqlFun.ExeCuteNonQuery("UPDATE dbo.tblNghiemThu SET duongDanFile=N'" + urlFile + "' WHERE sttNghiemThupr='" + hdfSttNT.Value.ToString() + "'"); //lấy mã dự án //xóa file cũ string duongdanfilecu_ = HttpContext.Current.Server.MapPath(duongdanfilecu.ToString()); if (System.IO.File.Exists(duongdanfilecu_)) { System.IO.File.Delete(duongdanfilecu_); } AsyncFileUpload.ClearState(); AsyncFileUpload.Dispose(); return; } else { //Xoa file neu da ton tai System.IO.File.Delete(path); AsyncFileUpload_UploadedComplete(sender, e); } } catch { return; } AsyncFileUpload.Dispose(); }
protected void afuArchivo_OnUploadedComplete(object sender, AsyncFileUploadEventArgs e) { try { bool fileOk = false; var path = BusinessVariables.Directorios.RepositorioTemporal; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } if (afuArchivo.HasFile) { string extension = Path.GetExtension(afuArchivo.FileName); if (extension != null) { var fileExtension = extension.ToLower(); string[] allowedExtensions = { ".xls", ".xlsx" }; foreach (string t in allowedExtensions.Where(t => fileExtension == t)) { fileOk = true; } } } if (fileOk) { try { hfFileName.Value = afuArchivo.FileName; afuArchivo.PostedFile.SaveAs(path + afuArchivo.FileName); Session["ArchivoCarga"] = afuArchivo.FileName; } catch (Exception ex) { throw new Exception(ex.Message); } } else { throw new Exception("Formato incorrecto"); } } catch (Exception ex) { if (_lstError == null) { _lstError = new List <string>(); } _lstError.Add(ex.Message); Alerta = _lstError; } }
protected void FileDocumento_UploadedFileError(object sender, AsyncFileUploadEventArgs e) { string sError = ""; if (e.StatusMessage == "The file attached is empty.") { sError = "El fichero no puede estar vacío."; } else { sError = e.StatusMessage; } ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "size", "top.$get(\"" + lblStatus.ClientID + "\").innerHTML = 'Se ha producido un error procesando la petición : " + sError + "';", true); }
void AsyncFileUpload1_UploadedComplete(object sender, AsyncFileUploadEventArgs e) { try { string path = ""; string urlFile = ""; if (Path.GetExtension(e.filename).Contains(".pdf") == false && Path.GetExtension(e.filename).Contains(".zip") && Path.GetExtension(e.filename).Contains(".rar")) { return; } SqlFunction sqlFun = new SqlFunction(HttpContext.Current.Session.GetConnectionString2()); //lấy mã dự án //string maDuAn = sqlFun.GetOneStringField("select maDuAn from tblDuAn where sttDuAnpr = N'" + hdfSttDA.Value + "'"); string tenFile = e.filename;//"VanBan" + hdfSTTVanBan.Value + ".pdf"; if (!System.IO.Directory.Exists(Server.MapPath("~/VanBan/" + HttpContext.Current.Session.GetDonVi().maDonVi + "/" + userControlVanBanChucNang.Value.ToString().Split('_')[0].ToString()))) { System.IO.Directory.CreateDirectory(Server.MapPath("~/VanBan/" + HttpContext.Current.Session.GetDonVi().maDonVi + "/" + userControlVanBanChucNang.Value.ToString().Split('_')[0].ToString())); } string strDate = DateTime.Now.ToString("dd_MM_yy_hhmmss"); string fileExtension = Path.GetExtension(tenFile).Replace(".", ""); tenFile = tenFile.Substring(tenFile.LastIndexOf("\\\\") + 1); tenFile = tenFile.Substring(0, tenFile.LastIndexOf(fileExtension)) + strDate + "." + fileExtension; tenFile = tenFile.Replace(" ", ""); path = string.Concat(Server.MapPath("/VanBan/" + HttpContext.Current.Session.GetDonVi().maDonVi + "/" + userControlVanBanChucNang.Value.ToString().Split('_')[0].ToString() + "/" + tenFile + "")); if (!System.IO.File.Exists(path)) { System.IO.File.Delete(path); AsyncFileUpload1.SaveAs(path); urlFile = "/VanBan/" + HttpContext.Current.Session.GetDonVi().maDonVi + "/" + userControlVanBanChucNang.Value.ToString().Split('_')[0].ToString() + "/" + tenFile + ""; sqlFun.ExeCuteNonQuery("UPDATE dbo.tblVanBanDA SET tenFile=N'" + urlFile + "' WHERE sttVBDApr='" + userControlVanBanpr.Value.ToString() + "'"); AsyncFileUpload1.ClearState(); AsyncFileUpload1.Dispose(); return; } else { //Xoa file neu da ton tai System.IO.File.Delete(path); AsyncFileUpload1_UploadedComplete(sender, e); } } catch { } AsyncFileUpload1.Dispose(); }
protected void afuFiles_UploadedComplete(object sender, AsyncFileUploadEventArgs e) { String fe = SqlExpressionBuilder.PrepareFilterExpression(HREmployeePhotoEntity.FLD_NAME_EmployeeID, OverviewEmployeeID.ToString(), SQLMatchType.Equal); IList <HREmployeePhotoEntity> lstmemberImageEntity = FCCHREmployeePhoto.GetFacadeCreate().GetIL(null, null, String.Empty, fe, DatabaseOperationType.LoadWithFilterExpression); HREmployeePhotoEntity memberImageEntity = new HREmployeePhotoEntity(); Boolean isSaveFlag = true; if (lstmemberImageEntity != null && lstmemberImageEntity.Count > 0) { isSaveFlag = false; } memberImageEntity.EmployeeID = this.OverviewEmployeeID; memberImageEntity.OriginalFileName = Path.GetFileName(e.FileName); memberImageEntity.CurrentFileName = Guid.NewGuid().ToString() + Path.GetExtension(e.FileName); memberImageEntity.FileType = ""; memberImageEntity.Extension = Path.GetExtension(e.FileName); memberImageEntity.Path = FileUploadConstants.HR.Employee + memberImageEntity.CurrentFileName; memberImageEntity.Remarks = String.Empty; memberImageEntity.IsCurrent = true; Int64 result = -1; if (isSaveFlag) { result = FCCHREmployeePhoto.GetFacadeCreate().Add(memberImageEntity, DatabaseOperationType.Add, TransactionRequired.No); } else { result = FCCHREmployeePhoto.GetFacadeCreate().Update(memberImageEntity, fe, DatabaseOperationType.Update, TransactionRequired.No); } if (result > 0) { MiscUtil.ShowMessage(lblMessage, "Image Uploaded Successfully.", false); BindMemberImageList(); } // file upload afuFiles.SaveAs(Server.MapPath(memberImageEntity.Path)); //LoadFileListGried BindMemberImageList(); }
protected void FileDocumento_UploadedComplete(object sender, AsyncFileUploadEventArgs e) { try { if (FileDocumento.HasFile) { string strFichero = Server.MapPath(".") + @"\" + Path.GetFileName(e.FileName); /* * * FileDocumento.SaveAs(strFichero); * FileStream fs = new FileStream(strFichero, FileMode.Open, FileAccess.Read); * * byte[] filebytes = new byte[fs.Length]; * fs.Read(filebytes, 0, Convert.ToInt32(fs.Length)); * fs.Close(); * Session["NOMBRE_ARCHIVO"] = Path.GetFileName(e.filename); * Session["ARCHIVO"] = filebytes; * */ HttpPostedFile selectedFile = FileDocumento.PostedFile; byte[] ArchivoEnBinario = new Byte[0]; if (selectedFile.ContentLength != 0) { string sFichero = selectedFile.FileName; //Grabo el archivo en base de datos ArchivoEnBinario = new Byte[selectedFile.ContentLength]; //Crear el array de bytes con la longitud del archivo selectedFile.InputStream.Read(ArchivoEnBinario, 0, selectedFile.ContentLength); //Forzar al control del archivo a cargar los datos en el array } Session["NOMBRE_ARCHIVO"] = Path.GetFileName(e.FileName); Session["ARCHIVO"] = ArchivoEnBinario; } else { Session["NOMBRE_ARCHIVO"] = null; Session["ARCHIVO"] = null; } } catch (Exception ex) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "size", "top.$get(\"" + lblStatus.ClientID + "\").innerHTML = 'Se ha producido un error procesando la petición : " + ex.Message.ToString() + "';", true); } }
protected void airporttaxUploadComplete(object sender, AsyncFileUploadEventArgs e) { try { contentUpload uploaded = uploaderFile(airporttaxUpload); if (!string.IsNullOrEmpty(uploaded.fileName) && uploaded.errorMessage == null) { } else { throw new ArgumentException("the first argument fail"); } } catch (Exception) { throw; } }
protected void tiketUploadComplete(object sender, AsyncFileUploadEventArgs e) { try { contentUpload uploaded = uploaderFile(tiketUpload); if (!string.IsNullOrEmpty(uploaded.fileName) && uploaded.errorMessage == null) { } else { throw new ArgumentException("the first argument cannot be less than the second"); } } catch (Exception) { throw; } }
protected void afuArchivo_OnUploadedComplete(object sender, AsyncFileUploadEventArgs e) { try { if (TamañoArchivo > 0) { if ((double.Parse(e.FileSize) / 1024) > (10 * 1024)) { Response.Write("Size is limited to 2MB"); throw new Exception(string.Format("El tamaño maximo de carga es de {0}MB", "10")); } } List <string> lstArchivo = Session["FilesComment"] == null ? new List <string>() : (List <string>)Session["FilesComment"]; if (lstArchivo.Any(archivosCargados => archivosCargados.Split('_')[0] == e.FileName.Split('\\').Last())) { return; } string extension = Path.GetExtension(e.FileName.Split('\\').Last()); if (extension == null) { return; } string filename = string.Format("{0}_{1}_{2}{3}{4}{5}{6}{7}{8}", e.FileName.Split('\\').Last().Replace(extension, string.Empty), lblNoticket.Text, DateTime.Now.Day, DateTime.Now.Month, DateTime.Now.Year, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, extension); AsyncFileUpload uploadControl = (AsyncFileUpload)sender; if (!Directory.Exists(BusinessVariables.Directorios.RepositorioTemporalMascara)) { Directory.CreateDirectory(BusinessVariables.Directorios.RepositorioTemporalMascara); } uploadControl.SaveAs(BusinessVariables.Directorios.RepositorioTemporalMascara + filename); lstArchivo.Add(filename); Session["FilesComment"] = lstArchivo; } catch (Exception ex) { if (_lstError == null) { _lstError = new List <string>(); } _lstError.Add(ex.Message); Alerta = _lstError; } }
protected void FilePicture_UploadedComplete(object sender, AsyncFileUploadEventArgs e) { var i = 0; while (!filePicture.HasFile && i < 50) { Thread.Sleep(100); i++; } // TODO: Mover isso para o Presenter/BO? string relativeFileName = "~/" + UploadTempPath + "/" + e.FileName; if (filePicture.HasFile) { Bitmap bmp = (Bitmap)Bitmap.FromStream(filePicture.PostedFile.InputStream); bmp = ImageProcessing.Resize(bmp, new Size(160, 120)); SaveImageTemp(bmp, relativeFileName); } }
protected void afDosnload_OnUploadedComplete(object sender, AsyncFileUploadEventArgs e) { try { AsyncFileUpload uploadControl = (AsyncFileUpload)sender; if (File.Exists(BusinessVariables.Directorios.RepositorioCarrusel + e.FileName.Split('\\').Last())) { File.Delete(BusinessVariables.Directorios.RepositorioCarrusel + e.FileName.Split('\\').Last()); } uploadControl.SaveAs(BusinessVariables.Directorios.RepositorioCarrusel + e.FileName.Split('\\').Last()); } catch (Exception ex) { if (_lstError == null) { _lstError = new List <string>(); } _lstError.Add(ex.Message); Alerta = _lstError; } }
protected void afuFiles_UploadedComplete(object sender, AsyncFileUploadEventArgs e) { CMBillUploadInfoEntity ent = new CMBillUploadInfoEntity(); ent.BillID = this.CMBillID; ent.OriginalFileName = Path.GetFileName(e.FileName); ent.CurrentFileName = Guid.NewGuid().ToString() + Path.GetExtension(e.FileName); ent.FileType = ""; ent.Extension = Path.GetExtension(e.FileName); ent.Path = FileUploadConstants.Bill.BILL_UPLOAD + ent.CurrentFileName; ent.Remarks = String.Empty; FCCCMBillUploadInfo.GetFacadeCreate().Add(ent, DatabaseOperationType.Add, TransactionRequired.No); // file upload afuFiles.SaveAs(Server.MapPath(ent.Path)); //LoadFileListGried BindCMBillUploadInfoList(); }
protected void ajaxFileUpload_UploadedComplete(object sender, AsyncFileUploadEventArgs e) { if (ValidateImageUpload(Path.GetFileName(ajaxFileUpload.FileName))) { int srNo = 1; List <CustomerLocationPic> pics = null; string imageName = Path.GetFileName(ajaxFileUpload.FileName); /*Initially...* */ string tempImageName = Guid.NewGuid() + "-" + imageName; ajaxFileUpload.SaveAs(Server.MapPath("~/CustomerDocs/LocationPics/" + tempImageName)); tempImageName = "../CustomerDocs/LocationPics/" + tempImageName; imageName = tempImageName; //Altered By Neeta.... //ajaxFileUpload.SaveAs(Server.MapPath("~/CustomerDocs/LocationPics/" + imageName)); // string tempImageName = imageName; if (ViewState[SessionKey.Key.PagedataTable.ToString()] != null) { pics = (List <CustomerLocationPic>)ViewState[SessionKey.Key.PagedataTable.ToString()]; } else { pics = new List <CustomerLocationPic>(); } if (pics.Count > 0) { //srNo = pics.Max(p => p.RowSerialNo) + 1; srNo = pics.Count + 1; } pics.Add(new CustomerLocationPic { RowSerialNo = srNo, LocationPicture = imageName }); CustomerLocationPicturesList = pics; hidCount.Value = pics.Count == 0 ? string.Empty : pics.Count.ToString(); grvShutter.DataSource = pics; grvShutter.DataBind(); } }
protected void AsyncUpldItemImage_UploadedComplete(object sender, AsyncFileUploadEventArgs e) { // System.Threading.Thread.Sleep(1000); Session["AsyncUpldItemImage"] = null; if (Session["AsyncUpldItemImage"] == null && AsyncUpldItemImage.HasFile) { Session["AsyncUpldItemImage"] = AsyncUpldItemImage; } else if (Session["AsyncUpldItemImage"] != null && (!AsyncUpldItemImage.HasFile)) { AsyncUpldItemImage = (AsyncFileUpload)Session["AsyncUpldItemImage"]; } else if (AsyncUpldItemImage.HasFile) { Session["AsyncUpldItemImage"] = AsyncUpldItemImage; } if (((AsyncFileUpload)Session["AsyncUpldItemImage"]).HasFile) { string ImageName = ((AsyncFileUpload)Session["AsyncUpldItemImage"]).FileName; string directory = Server.MapPath(uploadToDirectory + ImageName); Bitmap originalBMP = new Bitmap(((AsyncFileUpload)Session["AsyncUpldItemImage"]).FileContent); originalBMP.Save(directory); originalBMP.Dispose(); //hfImageName.Value = ImageName; // ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "image", "top.$get(ImgPrev).src ='" + uploadToDirectory + ImageName + "';", true); //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "image", "top.$get(\"" + PrevImage.ClientID + "\").src = '" + uploadToDirectory + ImageName + "';", true); // ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "SetImageName", "document.getElementById(\"" + hfImageName.ClientID + "\").value='" + ImageName + "';", true); } //UploadedImageName = strImageName; }
void fuEmpresa_UploadedComplete(object sender, AsyncFileUploadEventArgs e) { var mensaje = String.Empty; var script = new StringBuilder(""); try { if (fuEmpresa.HasFile) { var fechaHora = DateTime.Now.ToString("ddMMyyyyhhmmss"); string nombreArchivo = Path.GetFileNameWithoutExtension(e.FileName); string extension = Path.GetExtension(e.FileName); string rutaGuardar = MapPath("~/Archivos/Imagenes/Empresa/" + txtRuc.Text.Trim() + "/" + nombreArchivo + "_" + fechaHora + extension); var directorio = MapPath("~/Archivos/Imagenes/Empresa/" + txtRuc.Text.Trim()); if (!Directory.Exists(directorio)) { Directory.CreateDirectory(directorio); } fuEmpresa.SaveAs(rutaGuardar); hdnEmpresaImagen.Value = rutaGuardar; // Session["sEmpresaImagen"] = rutaGuardar; Session["sEmpresaImagen"] = "~/Archivos/Imagenes/Empresa/" + txtRuc.Text.Trim() + "/" + nombreArchivo + "_" + fechaHora + extension; script.Append("document.getElementById('" + hdnEmpresaImagen.ClientID + "').value = '" + rutaGuardar + "';"); // script.Append("alert(document.getElementById('" + hdnEmpresaImagen.ClientID + "').value);"); } } catch (Exception ex) { bool rethrow = ExceptionPolicy.HandleException(ex, Constantes.ExcepcionPoliticaPresentacion); mensaje = rethrow ? ex.Message : Constantes.ExcepcionPoliticaPresentacion; script.Append("MostrarMensaje('" + mensaje + "');"); } RegistrarScript(script.ToString(), "CargaLogo"); }
protected void fileUploadComplete(object sender, AsyncFileUploadEventArgs e) { string folderPath = ConfigurationManager.AppSettings["folderPath"]; Random rndm = new Random(); string filePath = Server.MapPath(folderPath) + "\\" + rndm.Next() + e.FileName.ToString(); fileUpload1.SaveAs(filePath); var buf = new byte[fileUpload1.FileContent.Length]; fileUpload1.FileContent.Read(buf, 0, (int)fileUpload1.FileContent.Length); System.Data.DataTable dt = new System.Data.DataTable(); dt.Columns.Add("Name"); dt.Columns.Add("Grade"); dt.Columns.Add("Rank"); object[] aa = buf.Cast <object>().ToArray(); dt.LoadDataRow(aa, true); ImportDataToGrid(filePath); }
//protected void LinkButtonLetterOfEnt_Click(object sender, EventArgs e) //{ // if (FileUploadLetterOfEnt.HasFile) // { // string extension = Path.GetExtension(FileUploadLetterOfEnt.PostedFile.FileName); // string filename = "Applicant-" + applicantID + "-Letter Of Entitlement" + extension; // string path = Server.MapPath("/Applicant_Data/applicant-" + applicantID); // if (!Directory.Exists(path)) // { // Directory.CreateDirectory(path); // } // if (loe != null) // File.Delete(Server.MapPath(loe)); // FileUploadLetterOfEnt.SaveAs(path + "/" + filename); // ApplicantReg obj = new ApplicantReg(); // obj.ApplicantID = applicantID; // obj.saveLOE("Applicant_Data/applicant-" + applicantID + "/" + filename); // DataSet dset = obj.retrieveData(applicantID); // loadData(dset); // } //} void AsyncFileUploadFard_UploadedComplete(object sender, AsyncFileUploadEventArgs e) { if (AsyncFileUploadFard.HasFile) { string extension = Path.GetExtension(AsyncFileUploadFard.PostedFile.FileName); string filename = "Applicant-" + applicantID + "-Fard" + extension; string path = Server.MapPath("/Applicant_Data/applicant-" + applicantID); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } if (fard != null) { File.Delete(Server.MapPath(fard)); } AsyncFileUploadFard.SaveAs(path + "/" + filename); ApplicantReg obj = new ApplicantReg(); obj.ApplicantID = applicantID; obj.saveFard("Applicant_Data/applicant-" + applicantID + "/" + filename); DataSet dset = obj.retrieveData(applicantID); loadData(dset); } }
//protected void AjaxFileUploadEvent(object sender, AjaxFileUploadEventArgs e) //{ // string filename = System.IO.Path.GetFileName(e.FileName); // const string strUploadPath = "~/Upload/"; // AjaxFileUpload11.SaveAs(Server.MapPath(strUploadPath) + filename); //} protected void FileUploadComplete(object sender, AsyncFileUploadEventArgs e) { if (Session["login"] != null && Session["UserName"] != null) { if ((bool)Session["login"]) { if (!Directory.Exists(UploadFolderPath + Session["FullName1"])) { string path = Server.MapPath(UploadFolderPath + Session["FullName1"] + ""); Directory.CreateDirectory(path); string filename = Path.GetFileName(AsyncFileUpload1.FileName); AsyncFileUpload1.SaveAs(Server.MapPath(UploadFolderPath) + Session["FullName1"] + "/" + filename); UpdateValueImg(UploadFolderPath + Session["FullName1"] + "/" + filename); } else { string filename = Path.GetFileName(AsyncFileUpload1.FileName); AsyncFileUpload1.SaveAs(Server.MapPath(UploadFolderPath) + Session["FullName1"] + "/" + filename); UpdateValueImg(UploadFolderPath + Session["FullName1"] + "/" + filename); } } } }
/// <summary> /// Handles the UploadedComplete event of the fileKey control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="AsyncFileUploadEventArgs" /> instance containing the event data.</param> protected void fileKey_UploadedComplete(object sender, AsyncFileUploadEventArgs e) { //keyBytes = fileKey.FileBytes; _postedKey = fileKey.PostedFile; }
// Save uploaded image or file to uplaod folder protected void asyncImgUpload_UploadedComplete(object sender, AsyncFileUploadEventArgs e) { string filename = System.IO.Path.GetFileName(asyncImgUpload.FileName); asyncImgUpload.SaveAs(Server.MapPath(this.FolderPath) + filename); }
protected void AsyncFileUploadCustomerAttachment_UploadedComplete(object sender, AsyncFileUploadEventArgs e) { string imageName = Path.GetFileName(AsyncFileUploadCustomerAttachment.FileName); if (File.Exists(Server.MapPath("~/UploadedFiles/") + imageName) == true) { File.Delete(Server.MapPath("~/UploadedFiles/") + imageName); } AsyncFileUploadCustomerAttachment.SaveAs(Server.MapPath("~/UploadedFiles/" + imageName)); lnkDownload.Visible = true; lnkDownload.Text = imageName; }
protected void file_upload_OnUploadedComplete(object sender, AsyncFileUploadEventArgs e) { }
void AsyncFileUpload1_UploadedFileError(object sender, AsyncFileUploadEventArgs e) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "error", "top.$get(\"" + uploadResult.ClientID + "\").innerHTML = 'Error: " + e.StatusMessage + "';", true); }
protected void MicrowaveTopology_AsyncFileUpload_UploadedComplete(object sender, AsyncFileUploadEventArgs e) { }
private void ProcessUpload(AsyncFileUploadEventArgs e) { if (e.FileName == null) { return; } ModConfigBase controller = (ModConfigBase)ConfigHelper.ModClass("UploadConfig"); string types = ""; if (AllowAttachments) { types += controller.ModConfiguration.Settings["AllowedAttachmentTypes"].ToString(); } if (AllowImageUploads) { if (types != "") { types += ","; } types += controller.ModConfiguration.Settings["AllowedImageTypes"].ToString(); } string[] allowedTypes = types.Split(','); //int fileSizeLimit = 10; //Convert.ToInt32(controller.ModConfiguration.Settings["FileSizeLimit"].ToString()); string uploadpath = controller.ModConfiguration.Settings["FileUploadLocation"].ToString(); string filext = Path.GetExtension(AsyncFileUpload1.PostedFile.FileName).Replace(".", ""); string contentType = AsyncFileUpload1.PostedFile.ContentType; bool allowed = false; if (contentType.Contains("image") && !AllowImageUploads) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "prohibited", "$(function() {top.$get(\"" + uploadResult.ClientID + "\").innerHTML = 'Image upload prohibited';});", true); AsyncFileUpload1.FailedValidation = true; return; } if (!contentType.Contains("image") && !AllowAttachments) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "prohibited", "$(function() {top.$get(\"" + uploadResult.ClientID + "\").innerHTML = 'File attachments prohibited';});", true); AsyncFileUpload1.FailedValidation = true; return; } foreach (string allowedType in allowedTypes) { if (filext == allowedType) { allowed = true; break; } } if (!allowed || (int.Parse(e.FileSize) > (FileSizeLimit * (1024 * 1024)))) { AsyncFileUpload1.FailedValidation = true; return; } var name = Path.GetFileName(e.FileName); if (contentType.Contains("image")) { uploadpath = "/Gallery"; } string savePath = Page.MapPath(String.Format("{0}/{1}/{2}", uploadpath, HttpContext.Current.User.Identity.Name, name.Replace(" ", "+"))); if (File.Exists(savePath)) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "exists", "$(function() {top.$get(\"" + uploadResult.ClientID + "\").innerHTML = 'File already exists';});", true); AsyncFileUpload1.FailedValidation = true; return; } ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "size", "$(function() {top.$get(\"" + uploadResult.ClientID + "\").innerHTML = 'Uploaded size: " + e.FileSize + "';});", true); if (!Directory.Exists(Page.MapPath(String.Format("{0}/{1}", uploadpath, HttpContext.Current.User.Identity.Name)))) { Directory.CreateDirectory( Page.MapPath(String.Format("{0}/{1}", uploadpath, HttpContext.Current.User.Identity.Name))); } if (contentType.Contains("image")) { if (e.FileName != null && AllowImageUploads) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "tag", "$(function() {top.$get(\"" + imageTag.ClientID + "\").innerHTML = '[img]" + String.Format("{0}/{1}/{2}", uploadpath, HttpContext.Current.User.Identity.Name, name.Replace(" ", "+")) + "[/img]';});", true); } } else { if (e.FileName != null && AllowAttachments) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "tag", "$(function() {top.$get(\"" + imageTag.ClientID + "\").innerHTML = '[file=" + e.FileName + "]" + String.Format("{0}/{1}/{2}", uploadpath, HttpContext.Current.User.Identity.Name, name.Replace(" ", "+")) + "[/file]';});", true); } } AsyncFileUpload1.SaveAs(savePath); if (contentType.Contains("image")) { string thumbPath = Page.MapPath(String.Format("{0}/{1}/thumbnail/{2}", uploadpath, HttpContext.Current.User.Identity.Name, name.Replace(" ", "+"))); if (!Directory.Exists(Page.MapPath(String.Format("{0}/{1}/thumbnail", uploadpath, HttpContext.Current.User.Identity.Name)))) { Directory.CreateDirectory(Page.MapPath(String.Format("{0}/{1}/thumbnail", uploadpath, HttpContext.Current.User.Identity.Name))); } GalleryFunctions.CreateThumbnail(savePath, thumbPath, 100); } }
void AsyncFileUpload_UploadedFileError(object sender, AsyncFileUploadEventArgs e) { }
private void AsyncFileUpload1UploadedComplete(object sender, AsyncFileUploadEventArgs e) { ProcessUpload(e); }
/// <summary> /// Handles the UploadedComplete event of the fileCER control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="AsyncFileUploadEventArgs" /> instance containing the event data.</param> protected void fileCER_UploadedComplete(object sender, AsyncFileUploadEventArgs e) { //cerBytes = fileCER.FileBytes; _postedCer = fileCER.PostedFile; }
protected void Candidate_Site3_AsyncFileUpload_UploadedComplete(object sender, AsyncFileUploadEventArgs e) { }