Hi,
Here is the demo ,
#1 ,modify the uploader.UploadUrl to the action url :
- @{
- CuteWebUI.MvcUploader uploader = new CuteWebUI.MvcUploader(HttpContext.Current);
-
- uploader.Name = "MyUploader";
- uploader.AllowedFileExtensions = "*.png,*.jpg,*.rar";
- uploader.MaxSizeKB = 200;
- uploader.UploadUrl = Url.Action("UploadHandler");
-
- @Html.Raw(uploader.Render());
- }
#2 , in the action UpoadHandler, do this way :
- [HttpPost]
- public ActionResult UploadHandler()
- {
- CuteWebUI.MvcUploader uploader = new CuteWebUI.MvcUploader(System.Web.HttpContext.Current);
- uploader.AllowedFileExtensions = "*.png,*.jpg,*.rar";
- uploader.MaxSizeKB = 200;
- uploader.PreProcessRequest();
-
- if (uploader.IsValidationRequest)
- {
- CuteWebUI.MvcUploadFile file = uploader.GetValidatingFile();
- if (file.FileSize < 100000)
- {
- uploader.WriteValidationError("File is too small");
- }
- else
- {
- uploader.WriteValidationOK("OK");
- }
- Response.End();
- }
-
- return View();
- }
This way is just help you move the code from UploadHandler.ashx to the mvc controller .
You shall handle the uploader postback like our samples do .
Regards,
Terry