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
;
}
}
查看全文
相关阅读:
nginx简单配置
解决 eclipse出现 Address already in use: bind
JavaScript 正则表达式学习
RabbitMQ的介绍与spring整合
RabbitMQ的安装与客户端的简单实用
java中的break与continue
书单
(七)SpringBoot2.0基础篇- application.properties属性文件的解析及获取
(六)SpringBoot2.0基础篇- MyBatis、Redis整合(JedisCluster集群连接)
(五)SpringBoot2.0基础篇- Mybatis与插件生成代码
原文地址:https://www.cnblogs.com/xiaodi/p/121901.html
最新文章
LazyMan深入解析和实现
localStorage的黑科技-js和css缓存机制
动态加载css方法实现和深入解析
hash实现锚点平滑滚动定位
window.onload多个共存
YUI Compressor压缩失效的场景-eval和with
解决 jQuery.UI.Resizable aspectRatio在init后无法重新设置
IE条件注释,嗅探低版本IE用户,并引导升级
【Vscode】 前端项目文件自动格式化(.Vue,.js)
【.Net core】EFCore——Code First生成数据库与表
热门文章
【Git】Git-常用命令备忘录(三)
【.Net core】ASP.NET Core 中的路由
【Git】Git-常用命令备忘录(二)
【Git】Git-常用命令备忘录(一)
【One by one系列】Git一步步生成SSH密钥,免密拉取远程仓库
【Nginx】Nginx部署实战——静态文件+反向代理+均衡负载+https+websocket
【Node.js】匿名函数-闭包-Promise
【One by one系列】一步步学习TypeScript
年末十一月末
关于三元运算符
Copyright © 2011-2022 走看看