protected void uploadControl_FilesUploadComplete(object sender, DevExpress.Web.FilesUploadCompleteEventArgs e) { if (uploadControl.UploadedFiles != null && uploadControl.UploadedFiles.Length > 0) { for (int i = 0; i < uploadControl.UploadedFiles.Length; i++) { UploadedFile file = uploadControl.UploadedFiles[i]; if (file.IsValid && file.FileName != "") { using (var stream = file.FileContent) { // If you need any additional checks, perform them here before saving the file if (!IsValidImage(stream)) { file.IsValid = false; e.ErrorText = "Validation failed!"; } else { string fileName = string.Format("{0}{1}", MapPath("~/UploadingFiles/Images/"), file.FileName); file.SaveAs(fileName, true); } } } } } }
protected void uploadControl_FilesUploadComplete(object sender, DevExpress.Web.FilesUploadCompleteEventArgs e) { if (uploadControl.UploadedFiles != null && uploadControl.UploadedFiles.Length > 0) { for (int i = 0; i < uploadControl.UploadedFiles.Length; i++) { UploadedFile file = uploadControl.UploadedFiles[i]; if (file.IsValid && file.FileName != "") { // Check if the uploaded file overflows the maximum directory size const long MaxDirectorySize = 10000000; // bytes long directorySize = GetDirectorySize(MapPath("~/UploadingFiles/Images/")); if (file.ContentLength + directorySize > MaxDirectorySize) { file.IsValid = false; e.ErrorText = "Maximum directory size exceeded!"; } else { string fileName = string.Format("{0}{1}", MapPath("~/UploadingFiles/Images/"), file.FileName); file.SaveAs(fileName, true); } } } } }
protected void UploadControl_FilesUploadComplete(object sender, DevExpress.Web.FilesUploadCompleteEventArgs e) { try { foreach (UploadedFile file in UploadControl.UploadedFiles) { //string dosyaAdiUret = DateTime.Now.ToString().Replace(".", "").Replace(":", "").Replace(" ", ""); string uploadFolder = Server.MapPath("~/App_Data/UploadDirectory/"); string resultExtension = Path.GetExtension(file.FileName); string resultFileName = Path.ChangeExtension(Path.GetRandomFileName(), resultExtension); string fileName = resultFileName;//e.UploadedFile.FileName; file.SaveAs(uploadFolder + fileName); e.CallbackData = fileName; Guid UserGUID = new Guid(Membership.GetUser().ProviderUserKey.ToString()); var sonuc = db.I_TemlikRapor_Excel(uploadFolder + fileName, UserGUID).ToList(); //var sonuc = db.I_AktivasyonAraRapor_Excel(uploadFolder + fileName, UserGUID).ToList().FirstOrDefault().Sonuc; } ////ASPxGridView1.DataSource = DataProvider.GetCagriIstekYenile(); ////ASPxGridView1.DataSourceID = String.Empty; ////ASPxGridView1.DataBind(); //DosyaYuklemePopup.JSProperties["cpVisible"] = "false"; e.CallbackData = "success"; } catch (Exception hata) { e.CallbackData = "error: " + hata.Message; } }
protected void uploadControl_FilesUploadComplete(object sender, DevExpress.Web.FilesUploadCompleteEventArgs e) { for (int i = 0; i < uploadControl.UploadedFiles.Length; i++) { UploadedFile file = uploadControl.UploadedFiles[i]; if (file.IsValid) { // Bad approach - possible Denial of Service // DoProcessing(file.FileBytes); // Good approach - use stream for large files using (var stream = file.FileContent) { DoProcessing(stream); } } } }
protected void uploadControl_FilesUploadComplete(object sender, DevExpress.Web.FilesUploadCompleteEventArgs e) { if (uploadControl.UploadedFiles != null && uploadControl.UploadedFiles.Length > 0) { for (int i = 0; i < uploadControl.UploadedFiles.Length; i++) { UploadedFile file = uploadControl.UploadedFiles[i]; if (file.IsValid) { string fileName = string.Format("{0}{1}", MapPath("~/UploadingFiles/Processing/"), Path.GetRandomFileName() + ".tmp"); file.SaveAs(fileName, true); // DoFileProcessing(fileName); } } } }
protected void ucFile_FilesUploadComplete(object sender, DevExpress.Web.FilesUploadCompleteEventArgs e) { var rand = new Random(); string tempDir = rand.Next(1, 999).ToString(); string newpath = MapPath("~/Content/Q/") + tempDir + "_\\"; ASPxUploadControl fup = sender as ASPxUploadControl; if (!Directory.Exists(newpath)) { Directory.CreateDirectory(newpath); } foreach (DevExpress.Web.UploadedFile file in fup.UploadedFiles) { file.SaveAs(newpath + file.FileName); } Session["tempDir"] = tempDir; }
protected void ucFile_FilesUploadComplete(object sender, DevExpress.Web.FilesUploadCompleteEventArgs e) { string newpath = MapPath("~/Content/Tickets/") + Session["ticket"] + "\\"; if (!Directory.Exists(newpath)) { Directory.CreateDirectory(newpath); } foreach (DevExpress.Web.UploadedFile file in ucFile.UploadedFiles) { file.SaveAs(newpath + file.FileName); } lblMsg.Text = "Files Uploaded Successfully"; popMsg.ShowOnPageLoad = true; SetRoot(); }