zoukankan
html css js c++ java
根据文件类型分别上传到各自的目录中
<
P
><
INPUT
type
="file"
runat
="server"
size
="50"
ID
="File1"
NAME
="File1"
></
P
>
<
P
><
INPUT
type
="file"
runat
="server"
size
="50"
ID
="File2"
NAME
="File2"
></
P
>
<
asp:LinkButton
id
="LinkButton1"
runat
="server"
>
上传
</
asp:LinkButton
>
<
A
href
="javascript:document.forms[0].reset()"
id
="LinkButton2"
>
重置
</
A
>
<
asp:Label
id
="Label1"
runat
="server"
></
asp:Label
>
private
void
Page_Load(
object
sender, System.EventArgs e)
{
//
在此处放置用户代码以初始化页面
if
(
this
.IsPostBack)
this
.UpLoad();
}
private
System.Boolean UpLoad()
{
System.Web.HttpFileCollection _files
=
System.Web.HttpContext.Current.Request.Files;
try
{
for
(System.Int32 _iFile
=
0
; _iFile
<
_files.Count; _iFile
++
)
{
//
Check to save file to the proper directory
System.Web.HttpPostedFile _postedFile
=
_files[_iFile];
System.String _fileName, _fileExtension;
_fileName
=
System.IO.Path.GetFileName(_postedFile.FileName);
//
文件名(包括后缀名)
_fileExtension
=
System.IO.Path.GetExtension(_fileName);
//
扩展名(包括点)
if
(_fileExtension
==
"
.gif
"
||
_fileExtension
==
"
.GIF
"
||
_fileExtension
==
"
.jpg
"
||
_fileExtension
==
"
.jpg
"
||
_fileExtension
==
"
.bmp
"
||
_fileExtension
==
"
.BMP
"
)
{
_postedFile.SaveAs(System.Web.HttpContext.Current.Request.MapPath(
"
../uploadfiles/images/
"
+
_fileName));
}
if
(_fileExtension
==
"
.swf
"
||
_fileExtension
==
"
.SWF
"
)
{
_postedFile.SaveAs(System.Web.HttpContext.Current.Request.MapPath(
"
../uploadfiles/flash/
"
+
_fileName));
}
}
Label1.Text
=
"
上传成功~
"
;
return
true
;
}
catch
(System.Exception Ex)
{
Label1.Text
=
Ex.Message;
return
false
;
}
}
查看全文
相关阅读:
Win10/UWP开发-Ink墨迹书写
Win10/UWP 让你的App使用上扫描仪
Win10/UWP新特性—Drag&Drop 拖出元素到其他App
UWP/Win10新特性系列—Drag&Drop 拖动打开文件
1、WIN2D学习记录(win2d实现JS雨天效果)
Windows 通用应用尝试开发 “51单片机汇编”总结
D2.Reactjs 操作事件、状态改变、路由
D1.1.利用npm(webpack)构建基本reactJS项目
UWP 动画系列之模仿网易云音乐动画
字符设备驱动之Led驱动学习记录
原文地址:https://www.cnblogs.com/xiaodi/p/121901.html
最新文章
负载均衡(Load Balancing)学习笔记(一)
一致性Hash(Consistent Hashing)原理剖析
分享一个.NET加密工具NetEncryptor v2.1.6(破解版)
C# 剪贴板中文乱码问题
HMAC-SHA256 & MD5 In C#
java中Hex.encodeHexString方法的c#实现
解决Oracle数据库不能导出空表的问题
windows操作笔记
(c#.net)前端js图片压缩将得到的base64字符串保存为图片
性能监控(转)
热门文章
优秀的HTML/CSS/JS插件
c# 抓取 js动态生成的HTML的工具:NHtmlUnit
不错的视频播放flash:flowplayer
C# 解析HTML格式字符串(HtmlAgilityPack)
使用 WinAppDeployCmd 部署Win10 App 到移动设备
Win10/UWP新特性—SharedStorageAccessManager 共享文件
Win10/UWP开发—凭据保险箱PasswordVault
Win10/UWP开发—SystemNavigationManager
Win10/UWP开发—使用Cortana语音与App后台Service交互
Win10/UWP开发—使用Cortana语音指令与App的前台交互
Copyright © 2011-2022 走看看