我正在发布一个简单的文本文件到一个asp.net MVC应用程序。当我使用下面的表单发布时,表单参数不是null。但档案是。任何想法我做错了什么?如何将文件发布到asp.net mvc应用程序?
<form method=post action="http://localhost/Home/ProcessIt"
enctype="application/x-www-form-urlencoded">
<input type=file id="thefile" name="thefile" />
<input type="submit" name="Submit" />
</form>
在asp.net MVC应用程序:
[HttpPost]
public ActionResult ProcessIt(FormCollection thefile)
{
HttpPostedFileBase file = Request.Files["thefile"];
...
}
http://stackoverflow.com/questions/5193842/file-upload-asp-net-mvc-3-0/5193851#5193851 – Shyju
如果我使用HttpPostedFileBase,该参数将是空。 – 4thSpace
为您的输入元素和方法参数使用相同的名称。按照我发布的链接 – Shyju