最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
asp.net C#(HtmlInputFile)上传图片代码
时间:2022-06-25 04:58:43 编辑:袖梨 来源:一聚教程网
asp教程.net c#(htmlinputfile)上传图片代码
先看一下htmlinputfile文件上传功能
httpfilecollection files = httpcontext.current.request.files;
if ( files.count == 1 )
{
httppostedfile postedfile = files[0];
if ( postedfile.filename != " " )
{
string filename = path.getextension(postedfile.filename);
string savepath = "/upload/ " + filename;
try
{
postedfile.saveas(savepath);
}
catch
{
this.showmessage( "上传照片失败! ");
throw;
}
}
}
下面一款应用实例
%@page language="c#" %>
<%@import namespace="system.io"%>
<%@import namespace="system.data"%>
<%@import namespace="system.data.sqlclient"%>
//显示图片
<%@page language="c#"%>
<%@import namespace="system.data"%>
<%@import namespace="system.data.sqlclient"%>
相关文章
- 《下一站江湖2》剑术突破方法 05-08
- 《剑星》废品平原全收集攻略 05-08
- 《辐射4》传说级怪物代码介绍 05-08
- 《下一站江湖2》诛尽杀绝化境卷获得方法 05-08
- 《剑星》无限之刃成就攻略 05-08
- 《辐射4》快速升级方法 05-08