我想上传多个文件,包括Word文档,PDF和图像。 我需要为文件使用单个输入,因为我们不知道将会上传多少个文件。在Asp Mvc上传单个输入的多个文件
我的代码是这个,但我有问题,我不能发送文件到服务器端。
控制器代码:
public ActionResult Create([Bind(Include = "Id,Content")] Message message, IEnumerable<HttpPostedFileBase> files)
{
if (ModelState.IsValid)
{
// Object save logic
SaveFiles(message,files);
return RedirectToAction("Index");
}
return View(message);
}
的视图代码部分:
<form name="registration" action="">
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
<label for="Content" >Content:</label>
<textarea class="form-control compose_content" rows="5" id="Content" name="content"></textarea>
<div class="fileupload">
Attachment :
<input id="files" name="files" type="file" multiple />
</div>
</div>
<button type="submit" class="btn btn-default compose_btn" >Send Message</button>
</form>
我没有与保存文件,并保存对象的问题。 唯一的问题: 文件列表为空。
显示你的'
我补充说,有问题。 –