lit*_*ris 11 asp.net-mvc file-upload
回发到我的控制器时,我的模型填充了正确的值,我的字符串字段有文件名,但Request.Files为空.
我在视图中的输入是:
<input id="SitePlan" name="SitePlan" type="file" value="<%= Html.Encode(Model.SitePlan) %>" />
Run Code Online (Sandbox Code Playgroud)
我的表单标签以:
<% using (Html.BeginForm(new { enctype = "multipart/form-data" }))
Run Code Online (Sandbox Code Playgroud)
还有什么我需要设置将字段发送回控制器吗?
Dav*_*vid 15
看一下渲染的<form>标签.没有Html.BeginForm声明只接受您正在使用的htmlAttributes.实际上,它使用html属性作为routeValues.试试这个...
<% using (Html.BeginForm("actionName", "controllerName", FormMethod.Post,
new { enctype = "multipart/form-data" })) { %>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11862 次 |
| 最近记录: |