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
;
}
}
查看全文
相关阅读:
耶鲁大学——斯金纳理论基础
耶鲁大学——弗洛伊德(基础)
for input 'WID' 报错
选中当前行wid
微信支付
vue.js列表渲染项目实例
批量删除
DIV 局部刷新
DIV块刷新
CMD DOS命令
原文地址:https://www.cnblogs.com/xiaodi/p/121901.html
最新文章
数据库事物
Python小练习005
Python小练习004
挂载Centos镜像-raw镜像
源码安装zabbix
redis
GTK+C应用界面工具安装,geany源码安装所需工具
vim正则表达式
python+uwsgi+nginx部署
python虚拟环境安装
热门文章
windows cmd命令
debian
python经典书籍,各阶段
耶鲁大学——我们应该如何交流思想
摄影基础(二)
python初学笔记(三)
python 初学笔记 (一)
摄影基础(一)
轻松谈话:谈话的力量
耶鲁大学——婴儿是如何思考?
Copyright © 2011-2022 走看看