.net:上传图片并将保存至指定目录下(支持PC端和移动端)
2024-09-29 01:23:53
页面:
<body>
<form id="formid" name="myform" action="Upload" method='post' enctype="multipart/form-data">
<table>
<tr>
<td>图片:</td>
<td><input type="file" name="file" accept="image/*" value="选择" /></td>
</tr>
</table>
<input type="submit" value="上传" />
</form>
</body>
后台:
public string Upload()
{
HttpPostedFileBase file = Request.Files["file"];
if (file.ContentLength > 0)
{
string savePath = Server.MapPath("~/Uploads/Pictures");
string failPath = savePath + "\\" + file.FileName;
file.SaveAs(failPath);
return “图片上传成功!”;
}
else
{
return "未选择图片!";
}
}
最新文章
- Be careful about the upper limit of integer
- [Unity3d插件]EasyTouch的初步使用
- web工程spring+ibatis单元测试
- WPF快速入门系列(1)——WPF布局概览
- 如何通过js实现图片预览功能
- PHP闭包研究
- CSS Layout
- android学习之BUG——The connection to adb is down, and a severe error has occured.
- CentOS安装最新的Mysql版本
- JAVA – 虚函数、抽象函数、抽象类、接口
- 使用gc、objgraph干掉python内存泄露与循环引用!
- round()函数 浮点数的四舍五入
- CentOS-7修改主机名
- 爬取豆瓣电影影评,生成wordcloud词云,并利用监督学习根据评论自动打星
- JS膏集02
- 20155305《网络对抗》PC平台逆向破解(二)
- Razor视图引擎 语法学习
- windows server 2008 修改域的密码策略
- SQL语句中的TOP(expression) [PERCENT] [WITH TIES] 用法
- Java SE练习题——求奇数
热门文章
- C0304 备份最后一天所有修改的文件
- C++ 类的多态三(多态的原理--虚函数指针--子类虚函数指针初始化)
- checkbox 更新回显
- 在项目中用过Spring的哪些方面?及用过哪些Ajax框架?
- Linux下搜索文件find、which、whereis、locate
- Java知识点梳理——多态
- OpenvSwitch自动化重新编译和安装
- 在VerilogHDL中调用VHDL的模块
- 关于小程序报错 缺少文件,错误信息:error: iconPath=../images/home.png, file not found
- druid