ASP.NET 2.0(C#)文件上传
来源:互联网 发布:比思论坛群组最新域名 编辑:程序博客网 时间:2024/05/19 18:38
ASP.NET 2.0(C#)文件上传
[ 2007-7-12 18:30:00 | By: SHARP_C ]
0
推荐
ASP.NET 2.0(C#)使用控件FileUpload实现文件上传:
上传代码:
if (FileUpload1.HasFile)
{
FileUpload1.SaveAs(Server.MapPath(".")+"/"+FileUpload1.FileName);
Label1.Text = "文件名称: " +FileUpload1.PostedFile.FileName +
{
FileUpload1.SaveAs(Server.MapPath(".")+"/"+FileUpload1.FileName);
Label1.Text = "文件名称: " +FileUpload1.PostedFile.FileName +
"<br>文件大小:" + FileUpload1.PostedFile.ContentLength/1024 +
" KB<br>文件类型:" + FileUpload1.PostedFile.ContentType+
"<br>文件上传路径:"+Server.MapPath(".")+"/"+FileUpload1.FileName.;
}
}
默认情况下,使用 FileUpload 控件上载到服务器的文件最大为 4MB 左右。
要更改大小限制,可以在 web.config.comments 文件(可以在 C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/CONFIG 的 ASP.NET 2.0 配置文件夹中找到)或应用程序的 web.config 文件中进行一些改动。
在 web.config.comments 文件中,查找一个名为 <executionTimeout>的节点
<httpRuntime
executionTimeout="110"
maxRequestLength="4096"
requestLengthDiskThreshold="80"
useFullyQualifiedRedirectUrl="false"
minFreeThreads="8"
minLocalRequestFreeThreads="4"
appRequestQueueLimit="5000"
enableKernelOutputCache="true"
enableVersionHeader="true"
requireRootedSaveASPath="true"
enable="true"
shutdownTimeout="90"
delayNotificationTimeout="5"
waitChangeNotification="0"
maxWaitChangeNotification="0"
enableHeaderChecking="true"
sendCacheControlHeader="true"
apartmentThreading="false" />
executionTimeout="110"
maxRequestLength="4096"
requestLengthDiskThreshold="80"
useFullyQualifiedRedirectUrl="false"
minFreeThreads="8"
minLocalRequestFreeThreads="4"
appRequestQueueLimit="5000"
enableKernelOutputCache="true"
enableVersionHeader="true"
requireRootedSaveASPath="true"
enable="true"
shutdownTimeout="90"
delayNotificationTimeout="5"
waitChangeNotification="0"
maxWaitChangeNotification="0"
enableHeaderChecking="true"
sendCacheControlHeader="true"
apartmentThreading="false" />
负责上载文件大小的设置是 maxRequestLength 属性。
根据扩展名获取文件类型:
string fileExt =System.IO.Path.GetExtension(FileUpload1.FileName);
文件扩展名是 . XXX,如 . EXE
- ASP.NET 2.0(C#)文件上传
- ASP.NET 2.0(C#)实现多文件上传
- asp.net 上传单个文件(c#)
- asp.net(C#) 大文件上传实例
- Asp.net(C#)多文件上传
- Asp.net(C#)多文件上传
- asp.net 上传文件 实现【C#】
- Asp.net(C#)多文件上传
- asp.net 2.0 文件上传
- Asp.net 2.0 上传文件
- asp.net文件上传
- ASP.Net文件上传
- ASP.Net文件上传
- ASP.NET上传文件
- asp.net文件上传
- ASP.NET上传文件
- Asp.Net 文件上传
- asp.net上传文件
- 如何提高个人效率?——停止做这9件事!
- XP桌面上的语言栏为什么不见了
- 效率低下之人的七大不良习惯
- INC 和 DEC
- 让你的个人效率翻三倍
- ASP.NET 2.0(C#)文件上传
- dbgrideh 使用技巧
- 使用c#获得cpu,硬盘的序列号
- 一些小网站记下来以后留着用~~嘿嘿
- WebService CXF学习(进阶篇3):对象传递
- 呵呵
- winter
- 用于时间操作的函数
- 研发项目管理中需注意的人性弱点