Javascript 在mvc中不使用提交按钮上载文件

Javascript 在mvc中不使用提交按钮上载文件,javascript,jquery,asp.net-mvc,asp.net-mvc-4,file-upload,Javascript,Jquery,Asp.net Mvc,Asp.net Mvc 4,File Upload,现在请提供一些ajax代码或jquery来上传文件,以及如何删除文件 I want to upload a file without using the submit button. The file must be uploaded at the moment the user picks it from browse file window. 请为此提供控件视图。 查看>>> 文件名1: 文件名2: 控制器>>> Please provide the control view for t

现在请提供一些ajax代码或jquery来上传文件,以及如何删除文件

I want to upload a file without using the submit button. The file must be uploaded at the moment the user picks it from browse file window.
请为此提供控件视图。
查看>>>
文件名1:
文件名2:
控制器>>>

Please provide the control view for this.
View>>>

<form action="FileUploadPost" method="post" enctype="multipart/form-data">

        <label for="file1">Filename1:</label>
        <input type="file" name="files" id="file3" />

        <label for="file2">Filename2:</label>
        <input type="file" name="files" id="file4" />

</form>
[HttpPost]
公共操作结果索引(IEnumerable文件)
{
foreach(文件中的var文件)
{
如果(file.ContentLength>0)
{
var fileName=Path.GetFileName(file.fileName);
var path=path.Combine(HttpContext.Server.MapPath(“~/App\u Data/Uploads”),文件名);
file.SaveAs(路径);
}
}
返回操作(“索引”);
}

您可以根据需要使用JQuery文件上传器控件。 它提供了通过“点击按钮”和“自动上传”上传文件的功能

自动上载:此功能将在您选择文件后立即上载文件

有关分步实施的详细信息,请参阅

[HttpPost]
        public ActionResult Index(IEnumerable<HttpPostedFileBase> files)
        {
            foreach (var file in files)
            {
                if (file.ContentLength > 0)
                {
                    var fileName = Path.GetFileName(file.FileName);
                    var path = Path.Combine(HttpContext.Server.MapPath("~/App_Data/Uploads"), fileName);
                    file.SaveAs(path);
                }
            }
            return RedirectToAction("Index");
        }