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;
}
}
}
下面一款应用实例
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"%>
python使用yaml格式文件的方法
完整指南微信小程序开发(项目从零开始)
Jev使用实用指南:从申请API Key到置信度路由,把TypeSafe决策模型接进自己的代码实用指南
VSCode 安装 Claude Code 插件 + ccswitch 配置 DeepSeek API 完整攻略(Windows新手)实实用指南
一篇文章搞懂Python的文件路径操作
使用pycharm进行绘图,图片无法显示的解决