一种方法是:
根据菲尔哈克http://haacked.com/archive/2010/07/16/uploading-files-with-aspnetmvc.aspx
你可以这样做:
<form action="" method="post" enctype="multipart/form-data">
<label for="file1">Filename:</label>
<input type="file" name="files" id="file1" />
<label for="file2">Filename:</label>
<input type="file" name="files" id="file2" />
<input type="submit" />
</form>
而且控制器..
[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(Server.MapPath("~/App_Data/uploads"), fileName);
file.SaveAs(path);
}
}
return RedirectToAction("Index");
}
秒ond方式:
使用KendoUI上传。它允许同步和异步地上传多个文件。
上传可用作文件输入元素的直接替换。
http://demos.kendoui.com/web/upload/index.html
澄清: IE的版本不支持多个文件选择。
你能告诉我们你上传的代码是什么吗? – 2012-08-09 16:36:20
我用plupload祝你好运。我已经在MVC3应用中使用它,并在客户端使用了每种方法(html5,flash,silverlight等)。 – BZink 2012-08-09 16:55:32
我想知道你错过了菲尔哈克的[文章](http://haacked.com/archive/2010/) 07/16/uploadloading-files-with-aspnetmvc.aspx)?你用什么关键字搜索...... – Yasser 2012-08-09 17:45:44