/// <summary> /// /// </summary> public FileUploadField.Builder FileUploadField(FileUploadField component) { #if MVC component.ViewContext = this.HtmlHelper != null ? this.HtmlHelper.ViewContext : null; #endif return(new FileUploadField.Builder(component)); }
public void onUploadBorrower(FileUploadField fileUpload, Ext.Net.Image image, Hidden hidden, string name) { string msg = ""; // Check that a file is actually being submitted. if (fileUpload.PostedFile.FileName == "") { X.MessageBox.Alert("Alert", "No file specified.").Show(); btnSaveSignatures.Disabled = true; btnSaveSignatures.Disabled = true; } else //else if file exists { // Check the extension. string extension = Path.GetExtension(fileUpload.PostedFile.FileName); switch (extension.ToLower()) { case ".bmp": case ".gif": case ".jpg": case ".png": case ".tiff": case ".jpeg": case ".tif": break; default: X.MessageBox.Alert("Alert", "This file type is not allowed.").Show(); return; } // Using this code, the saved file will retain its original // file name when it's placed on the server. string serverFileName = Path.GetFileName(fileUpload.PostedFile.FileName); string fullUploadPath = Path.Combine(uploadDirectory, name + serverFileName); string file = ""; string fileName = ""; try { //check if file already exists if (File.Exists(fullUploadPath)) { file = Path.GetFileNameWithoutExtension(serverFileName); file += DateTime.Now.ToString("M-dd-yyyy hhmmss.ff") + Path.GetExtension(serverFileName); fileName = file; file = Path.Combine(uploadDirectory, name + file); } else { file = fullUploadPath; fileName = serverFileName; } //save file fileUpload.PostedFile.SaveAs(file); msg = "File uploaded successfully."; btnSaveSignatures.Disabled = false; } catch (Exception err) { msg = err.Message; } X.MessageBox.Alert("Status", msg).Show(); imageFilename = "../../../Uploaded/Agreement/" + hdnLoanApplicationId.Value.ToString() + "/" + FormType.PromissoryNoteType.Name + "/" + name + fileUpload.PostedFile.FileName; image.ImageUrl = imageFilename; hidden.Value = imageFilename; } }
/// <summary> /// /// </summary> public FileUploadField.Builder FileUploadField(FileUploadField component) { return(new FileUploadField.Builder(component)); }