最新下载
热门教程
- 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"%>
相关文章
- 我的花园世界合种怎么组队 08-26
- 逆水寒手游育宠及新宠物有哪些内容 08-26
- 赛尔号巅峰之战索伦森关卡怎么通关 08-26
- 物华弥新鸟音山水钟有什么玩法技巧 08-26
- 米姆米姆哈怎么培养闪闪立羽鸮 08-26
- 光隙解语奶妈如何选择 08-26