不知道 Uploadify,但如果您想一次上传多个文件,请使用标准表单:
看法:
@using (Html.BeginForm("YourAction","YourController",FormMethod.Post,new { enctype="multipart/form-data"})) {
@Html.ValidationSummary(true)
<fieldset>
<legend>Message</legend>
//your html here
//as many input types you would like but they
//must have a same name attribute (files)
<input type="file" name="files"/>
</fieldset>
控制器:
[HttpPost]
public ActionResult YourAction(FormCollection values, IEnumerable<HttpPostedFileBase> files)
{
//do what you want with form values then for files
foreach (var file in files)
{
if (file.ContentLength > 0)
{
byte[] fileData = new byte[file.ContentLength];
file.InputStream.Read(fileData, 0, file.ContentLength);
//do what you want with fileData
}
}
}
因此,您将使用IEnumerable<HttpPostedFileBase> files
多个文件,HttpPostedFileBase file
单个文件,并将视图中的输入更改为
<input type="file" name="file"/>
问候。