ASP.NET MVC 文件上传
2016-02-14 10:30
567 查看
如果想要用HTML表单实作文件上传的功能,那么必须在输出的<form>表单标签加上一个enctype属性,且内容必须设定为multipart/form-data,要通过Html.BeginForm辅助方法新增额外的属性必须再加上第四个参数,并传入一个匿名对象即可。如下范例:
@using (Html.BeginForm("Upload", "File", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
@Html.TextBox("File1", "", new { type = "file", size = "25" })
<input type="submit" />
}
@using (Html.BeginForm("Upload", "File", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
@Html.TextBox("File1", "", new { type = "file", size = "25" })
<input type="submit" />
}
相关文章推荐
- beef集成metasploit教程
- asp.net中邮箱发送
- ASPNET开源项目
- ClassLoader, JavaAgent, Aspectj Weaving
- JVM参数设置
- How to Control a Lamp With Voice Commands and a Raspberry Pi
- 16.2.13 asp.net 学习随笔
- 树莓派 Raspberry Pi SD卡系统备份与还原
- ASP.NET对象的使用
- ASP.NET对象的使用
- Asp.Net alert弹出提示信息的几种方法总结
- 关于asp.net三种重定向方法的总结
- CRUD Operations In ASP.NET MVC 5 Using ADO.NET
- 让ASP.NET Web API支持POST纯文本格式(text/plain)的数据
- Asp.net MVC中的ViewData与ViewBag
- asp.net中邮箱发送
- asp.net mvc 利用过滤器进行网站Meta设置
- [ASP.NET MVC] ASP.NET Identity登入技术剖析
- ASPxUploadControl上传
- DevExpress ASP.NET 使用经验谈(9)- Dev控件客户端事件 ClientSideEvents