最新下载
热门教程
- 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"%>
相关文章
- 金铲铲之战幻灵武器选择推荐 07-01
- 崩坏星穹铁道斯缇科西亚若虫位置一览 07-01
- 洛克王国世界机甲小子捕捉方法 07-01
- XRoad(XRI币)排名是什么 07-01
- 金铲铲之战s14街头恶魔主c阵容构筑推荐 07-01
- 魔兽世界11.1雷鼓哑炮火箭怎么获得 07-01