我将 DropzoneJS 与 MVC 一起使用。文件上传正常,但动作不会显示另一个视图,重定向到另一个动作后也不会显示另一个视图。只是停留在调用它的同一视图上。
行动 :
[HttpPost]
public ActionResult FileUpload(HttpPostedFileBase file)
{
if(file != null)
{
string ext = Path.GetExtension(file.FileName);
if (file.ContentLength > 0 && ext == ".txt")
{
var fileName = Path.GetFileName(file.FileName);
if (fileName != null)
{
var path = Path.Combine(Server.MapPath("~/uploads"), fileName);
file.SaveAs(path);
}
}
}
return View("Report");
// This will redirect to action but will not display another view either:
// return RedirectToAction("Report");
}
视图调用自:
<div id="dropzone">
<form action="/Dashboard/FileUpload" class="dropzone clickable" id="demo-upload" method="post" enctype="multipart/form-data">
</form>
</div>