最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

asp.net 2.0的文件上傳(突破上傳限制4M)

 更新時(shí)間:2009年06月05日 23:26:20   作者:  
在asp.net 2.0中,因?yàn)橛辛薴ileupload控件,上傳文件十分簡單
復(fù)制代碼 代碼如下:

if (FileUpload1.HasFile)
try
{
FileUpload1.SaveAs("d:\\luceneData\\" + FileUpload1.FileName);
Label1.Text = "File name: " +
FileUpload1.PostedFile.FileName + "<br>" +
FileUpload1.PostedFile.ContentLength + " kb<br>" +
"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文件中,突破默認(rèn)上傳限制的4MB,比如
<httpRuntime
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" />
設(shè)置maxRequestLenth屬性,這里為11000KB,即11MB。
而對于多文件上傳,也很簡單,比如一個(gè)例子
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 += "<u>File #" + (i + 1) +
"</u><br>";
Label1.Text += "File Content Type: " +
userPostedFile.ContentType + "<br>";
Label1.Text += "File Size: " +
userPostedFile.ContentLength + "kb<br>";
Label1.Text += "File Name: " +
userPostedFile.FileName + "<br>";
userPostedFile.SaveAs(filepath + "\\" +
System.IO.Path.GetFileName(userPostedFile.FileName));
Label1.Text += "Location where saved: " +
filepath + "\\" +
System.IO.Path.GetFileName(userPostedFile.FileName) +
"<p>";
}
}
catch (Exception Ex)
{
Label1.Text += "Error: <br>" + Ex.Message;
}
}
}

相關(guān)文章

最新評論

黔东| 云霄县| 新乡县| 赣州市| 光山县| 思南县| 辽源市| 襄樊市| 浏阳市| 日照市| 扎鲁特旗| 桃源县| 遂昌县| 龙里县| 湘潭县| 依安县| 镇安县| 宣化县| 永丰县| 富锦市| 上虞市| 尉氏县| 信宜市| 富源县| 乌拉特中旗| 上栗县| 泰兴市| 内黄县| 象山县| 曲阳县| 尉犁县| 甘孜| 济源市| 且末县| 湖口县| 横峰县| 永吉县| 安多县| 扎鲁特旗| 庆城县| 临泉县|