All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
Apache伪静态html(URL Rewrite)设置法_[PHP教程]
收集ASP转ASP.NET过程典型问题_[Asp.Net教程]
Sql,server2005,sp1发布_[SQL,Server教程]
.NET自动字符编码识别程序库,NChardet_[Asp.Net教程]
ASP.NET如何保留两位小数点_.net资料_编程技术
C#中使用进度条
PHP,5.0中多态性的实现方案浅析_php资料_编程技术
PHP教程:实现网站的无限分类_[PHP教程]
PHP开发中常用的一些函数_[PHP教程]
Asp.net,2.0,C#实现压缩解压功能
Reading number is top 10 pictures
The money of more than 100 countries and regions12
Green sweet joey wong young old photos exposure
青春清纯美女大集合1
Summer is most suitable for young people to travel in China8
乳娘帕梅拉安德森1
Discharge accidentally Actresses by the breast4
刘亦菲写真集1
5 meters long centenarians python and melee was successfully capture king snake (figure)
Plump, too plump!1
中国女孩大胆自拍,显露完美身材3
Download software ranking
Boxer's Top ten classic battle4
金山office2007
matrix1
Tram sex maniac 2 (H) rar bag5
I'm come from Beijing2
Unix video tutorial9
尖东毒玫瑰A
Tram sex maniac 2 (H) rar bag18
Unix video tutorial5
美女游泳记
归海一刀 published in(发表于) 2014/1/30 1:17:06 Edit(编辑)
asp.net,2.0的文件上传(突破上传限制4M)_[Asp.Net教程]

asp.net,2.0的文件上传(突破上传限制4M)_[Asp.Net教程]

asp.net 2.0的文件上传(突破上传限制4M)_[Asp.Net教程]
在asp.net 2.0中,因为有了fileupload控件,上传文件十分简单,

if (FileUpload1.HasFile)
try
{
FileUpload1.SaveAs("d:\\luceneData\\" + FileUpload1.FileName);
Label1.Text = "File name: " +
FileUpload1.PostedFile.FileName + "
" +
FileUpload1.PostedFile.ContentLength + " kb
" +
"Content type: " +
FileUpload1.PostedFile.ContentType;
}
catch (Exception ex)
{
Label1.Text = "ERROR: " + ex.Message.ToString();
}
else
{
Label1.Text = "You have not specified a file.";
}

还可以在web.config文件中,突破默认上传限制的4MB,比如

executionTimeout="110"
maxRequestLength="11000"
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" />

设置maxRequestLenth属性,这里为11000KB,即11MB。

而对于多文件上传,也很简单,比如一个例子
string filepath = "d:\\luceneData\\";
HttpFileCollection uploadedFiles = Request.Files;

for (int i = 0; i < uploadedFiles.Count; i++)
{
HttpPostedFile userPostedFile = uploadedFiles[i];

try
{
if (userPostedFile.ContentLength > 0)
{
Label1.Text += "File #" + (i + 1) +
"

";
Label1.Text += "File Content Type: " +
userPostedFile.ContentType + "
";
Label1.Text += "File Size: " +
userPostedFile.ContentLength + "kb
";
Label1.Text += "File Name: " +
userPostedFile.FileName + "
";

userPostedFile.SaveAs(filepath + "\\" +
System.IO.Path.GetFileName(userPostedFile.FileName));

Label1.Text += "Location where saved: " +
filepath + "\\" +
System.IO.Path.GetFileName(userPostedFile.FileName) +
"

";
}
}
catch (Exception Ex)
{
Label1.Text += "Error:
" + Ex.Message;
}
}

}



添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.