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

Reading number is top 10 articles
ASP.NET技巧:如何在页面之间传递数据量较大的复杂数据?_.net资料_编程技术
SQL,Server的有效安装_mssql学习_编程技术
菜鸟的最爱,.NET经典代码汇总(一)_.net资料_编程技术
php-树形结构的算法_[PHP教程]
ASP.NET,Ajax调用WCF服务的代码示例_.net资料_编程技术
C#中父窗口和子窗口之间实现控件互操作_[Asp.Net教程]
ASP.NET,MVC+LINQ开发一个图书销售站点(4)-创建一个ASP.NET,MVC应用的原型_[Asp.Net教程]
开发某项目用到的全部50个Sql语句_[SQL Server教程]
在ASP.net中使用TinyMCE的小tip
Asp.net,MVC中页面标题的解决方法_[Asp.Net教程]
Reading number is top 10 pictures
Summer is most suitable for young people to travel in China1
网络游戏与脑残
Sexy women in 2013--1
超强高考作文
Photographed the passion of the clients and prostitutes in the sex trade picture2
赵惟依写真3
Ashlynn Brooke a group sexy photo2
Breasts woman big set 1
接财神,大吉大利,财源滚滚来
Perfect small Laurie1
Download software ranking
linux高级编程
matrix1
linux初级教程
Boxer's Top ten classic battle2
Unix video tutorial11
变速齿轮3.26
好色的外科大夫
天龙八部十二宫服务端
Unix video tutorial1
Take off clothes to survival
aaa published in(发表于) 2013/12/8 7:48:16 Edit(编辑)
ASP.NET,2,的文件上传_.net资料_编程技术

ASP.NET,2,的文件上传_.net资料_编程技术

ASP.NET 2 的文件上传_.net资料_编程技术-你的首页-uuhomepage.com

在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.