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
;
}
}
查看全文
相关阅读:
HOJ 2930 Perfect Fill IIl 线性递推
BZOJ 1269: [AHOI2006]文本编辑器editor Splay
linux shell常用快捷键(转)
【引用】Linux date命令
linux shell if 参数(转)
vsftpd 530 Permission denied(转)
捕获非广播包和非发给自己主机的数据包的原理是什么 混杂模式(转)
代理ARP(转)
Linux和Unix系统 关系和区别详细介绍(转)
路由表(转)
原文地址:https://www.cnblogs.com/xiaodi/p/121901.html
最新文章
PHP基础知识总结
EditText自定义边框和背景
SlidingDrawerActivity(抽屉)
J2SE复习笔记2线程
J2SE_IO复习笔记
appium快速入门
01、C#基础语法(一)
04、C#基础进阶
05、C#Winform(一)
06、C#Winform(二)
热门文章
02、C#基础语法(二)
03、C#面向对象
SGU 分类(转)
矩阵总结 ACM
HOJ 1016 Joseph's problem I 树状数组求第K大
splay总结
BZOJ 1588: [HNOI2002]营业额统计 Splay版(模板题)
CF 276C Little Girl and Maximum Sum 差分数列,线段树,splay
HOJ 1991 Happy 2005 HOJ 2635 Weights 快速幂
HDU 吉哥系列故事——完美队形II 騰訊馬拉松初賽第二輪D題
Copyright © 2011-2022 走看看