public ActionResult Customize_Progress_Bar(string myuploader) { using (CuteWebUI.MvcUploader uploader = new CuteWebUI.MvcUploader(System.Web.HttpContext.Current)) { uploader.UploadUrl = Response.ApplyAppPathModifier("~/UploadHandler.ashx"); //the data of the uploader will render as <input type='hidden' name='myuploader'> uploader.Name = "myuploader"; uploader.AllowedFileExtensions = "*.jpg,*.gif,*.png,*.bmp,*.zip,*.rar"; uploader.InsertText = "Select a file to upload"; //prepair html code for the view ViewData["uploaderhtml"] = uploader.Render(); //if it's HTTP POST: if (!string.IsNullOrEmpty(myuploader)) { //for single file , the value is guid string Guid fileguid = new Guid(myuploader); CuteWebUI.MvcUploadFile file = uploader.GetUploadedFile(fileguid); if (file != null) { //you should validate it here: //now the file is in temporary directory, you need move it to target location //file.MoveTo("~/myfolder/" + file.FileName); //set the output message ViewData["UploadedMessage"] = "The file " + file.FileName + " has been processed."; } } } return(View()); }
public ActionResult Persist_upload_file(string myuploader) { using (CuteWebUI.MvcUploader uploader = new CuteWebUI.MvcUploader(System.Web.HttpContext.Current)) { uploader.UploadUrl = Response.ApplyAppPathModifier("~/UploadHandler.ashx"); //the data of the uploader will render as <input type='hidden' name='myuploader'> uploader.Name = "myuploader"; uploader.AllowedFileExtensions = "*.jpg,*.gif,*.png,*.bmp,*.zip,*.rar"; uploader.MaxSizeKB = 10240; //tell uploader attach a button uploader.InsertText = "Upload File"; //prepair html code for the view ViewData["uploaderhtml"] = uploader.Render(); //if it's HTTP POST: if (!string.IsNullOrEmpty(myuploader)) { List <string> processedfiles = new List <string>(); //for multiple files , the value is string : guid/guid/guid foreach (string strguid in myuploader.Split('/')) { Guid fileguid = new Guid(strguid); CuteWebUI.MvcUploadFile file = uploader.GetUploadedFile(fileguid); if (file != null) { processedfiles.Add(file.FileName); } } if (processedfiles.Count > 0) { ViewData["UploadedMessage"] = string.Join(",", processedfiles.ToArray()) + " have been processed."; } } } return(View()); }
public ActionResult multiple_files_upload_control_file_number(string myuploader) { using (CuteWebUI.MvcUploader uploader = new CuteWebUI.MvcUploader(System.Web.HttpContext.Current)) { uploader.UploadUrl = Response.ApplyAppPathModifier("~/UploadHandler.ashx"); //the data of the uploader will render as <input type='hidden' name='myuploader'> uploader.Name = "myuploader"; uploader.AllowedFileExtensions = "*.jpg,*.gif,*.png,*.bmp,*.zip,*.rar"; uploader.MaxSizeKB = 10240; uploader.MultipleFilesUpload = true; //tell uploader attach a button uploader.InsertButtonID = "uploadbutton"; //prepair html code for the view ViewData["uploaderhtml"] = uploader.Render(); } return(View()); }
public ActionResult Drag_drop_file(string myuploader) { using (CuteWebUI.MvcUploader uploader = new CuteWebUI.MvcUploader(System.Web.HttpContext.Current)) { uploader.UploadUrl = Response.ApplyAppPathModifier("~/UploadHandler.ashx"); //the data of the uploader will render as <input type='hidden' name='myuploader'> uploader.Name = "myuploader"; uploader.AllowedFileExtensions = "*.jpg,*.gif,*.png,*.bmp,*.zip,*.rar"; uploader.MaxSizeKB = 1024; uploader.ManualStartUpload = true; uploader.InsertText = "Browse Files (Max 1M)"; uploader.MultipleFilesUpload = true; uploader.InsertButtonID = "InsertButton"; uploader.QueuePanelID = "QueuePanel"; //uploader.FileDropPanelID = "DropPanel"; //prepair html code for the view ViewData["uploaderhtml"] = uploader.Render(); //if it's HTTP POST: if (!string.IsNullOrEmpty(myuploader)) { string msgs = ""; foreach (string guidstr in myuploader.Split('/')) { //for single file , the value is guid string Guid fileguid = new Guid(guidstr); CuteWebUI.MvcUploadFile file = uploader.GetUploadedFile(fileguid); if (file != null) { //you should validate it here: //now the file is in temporary directory, you need move it to target location //file.MoveTo("~/myfolder/" + file.FileName); //set the output message msgs += "The file " + file.FileName + " has been processed.\r\n"; } } ViewData["UploadedMessage"] = msgs; } } return(View()); }
public ActionResult selecting_multiple_files(string myuploader) { using (CuteWebUI.MvcUploader uploader = new CuteWebUI.MvcUploader(System.Web.HttpContext.Current)) { uploader.UploadUrl = Response.ApplyAppPathModifier("~/UploadHandler.ashx"); //the data of the uploader will render as <input type='hidden' name='myuploader'> uploader.Name = "myuploader"; uploader.AllowedFileExtensions = "*.jpg,*.gif,*.png,*.bmp,*.zip,*.rar"; //allow select multiple files uploader.MultipleFilesUpload = true; //tell uploader attach a button uploader.InsertButtonID = "uploadbutton"; //prepair html code for the view ViewData["uploaderhtml"] = uploader.Render(); //if it's HTTP POST: if (!string.IsNullOrEmpty(myuploader)) { List <string> processedfiles = new List <string>(); //for multiple files , the value is string : guid/guid/guid foreach (string strguid in myuploader.Split('/')) { Guid fileguid = new Guid(strguid); CuteWebUI.MvcUploadFile file = uploader.GetUploadedFile(fileguid); if (file != null) { //you should validate it here: //now the file is in temporary directory, you need move it to target location //file.MoveTo("~/myfolder/" + file.FileName); processedfiles.Add(file.FileName); } } if (processedfiles.Count > 0) { ViewData["UploadedMessage"] = string.Join(",", processedfiles.ToArray()) + " have been processed."; } } } return(View()); }
/// <summary> /// Call the initialization of ajax uploader control /// </summary> /// <param name="context"></param> private void SetupUploader(HttpContext context) { using (CuteWebUI.MvcUploader uploader = new CuteWebUI.MvcUploader(context)) { uploader.UploadUrl = Response.ApplyAppPathModifier(VirtualPathUtility.ToAbsolute("~/UploadHandlerDocument.ashx")); //Set the max bytes allowed to be uploaded uploader.MaxSizeKB = Cotecna.Vestalis.Web.Properties.Settings.Default.MaxFileUploadSizeKB; //the data of the uploader will render as <input type='hidden' name='myuploader'> uploader.Name = "myuploader"; //File extensions allowed to execute the upload uploader.AllowedFileExtensions = Cotecna.Vestalis.Web.Properties.Settings.Default.ExtensionDocumentAllowed; //set the uploader do not automatically start upload after selecting files uploader.ManualStartUpload = true; //Flag to upload multiple files uploader.MultipleFilesUpload = true; uploader.InsertButtonID = "uploadbutton"; //prepair html code for the view ViewData["uploaderhtml"] = uploader.Render(); } }