MVC前台上传文件到服务器
来源:互联网 发布:php图书管理系统 编辑:程序博客网 时间:2024/05/20 05:53
mvc前台编辑上传文件页面
前台代码:
@using (Html.BeginForm("index", "test", FormMethod.Post, new { enctype="multipart/form-data"}))
{
<table>
<tr>
<td>
<input id="File1" type="file" name="File" />
</td>
<td>
<input id="Submit1" type="submit" value="submit" />
</td>
</tr>
</table>
}
后台编码:Directory需要引入system.IO命名空间
public class testController : Controller
{
// GET: test
public ActionResult Index(string File)
{
HttpPostedFileBase ff = Request.Files[" File"];
if (ff != null && ff.ContentLength != 0)
{
if (!Directory.Exists(Server.MapPath("Attach/")))
{
Directory.CreateDirectory("Attach/");
}
}
string filepath = Server.MapPath("Attach/") + File;
ff.SaveAs(filepath);//在服务器上保存上传文件
string[] readFile = System.IO.File.ReadAllLines(filepath);//读取txt文档存放在字符数组中
return View();
}
}
- MVC前台上传文件到服务器
- MVC文件上传到服务器
- 上传文件到服务器
- 上传文件到服务器
- 上传文件到服务器
- 上传文件到服务器
- 上传文件到服务器
- 上传文件到服务器
- 上传文件到服务器
- 上传文件到服务器
- 上传文件到服务器
- 上传文件到服务器
- 上传文件到服务器
- Spring mvc上传图片到本地服务器
- Python上传文件到服务器
- ABAP上传文件到服务器
- android文件上传到服务器
- Iphone上传文件到服务器
- 【JZ2440】自我学习记录【如何学习一个新的芯片:S3C2440】
- 图像分割之(五)边缘检测Laplace详解
- 使用TCP协议编写一个网络程序,设置服务器端的监听端口是8002,当与客户端建立连接后,服务器端向客户端发送数据“Hello, world”,客户端收到数据后打印输出
- Redis数据结构及其常用命令
- HDOJ 2040 亲和数
- MVC前台上传文件到服务器
- vb.net 教程 8-3 数据库操作9-3
- 判断是否为平衡二叉树
- Linux命令每日学之Ping
- 应用程序运行慢(cpu util 高)的一种可能原因
- 基于dockerfile的运维工具ansible和nginx安装
- FreeBASIC学习笔记——第09章 预编译
- 属性动画
- 如何使用charles代理转发请求