首 页 网络编程
网页制作 图形图象 操作系统 冲浪宝典
软件教学 认证考试

网络安全 网络办公 行业资讯 评测对比
您当前位置:站长天空 -> 认证考试-> 全国等级考试
大文件上传研究-ASP教程,ASP应用
作者:网友供稿 点击:389
推荐
西部数码-全国虚拟主机10强!20余项虚拟主机管理功能,全国领先!第6代双线路虚拟主机,南北访问畅通无阻!可在线rar解压,自动数据恢复设置虚拟目录等.免费赠送访问统计,企业邮局.Cn域名注册10元/年,自助建站480元起,免费试用7天,满意再付款!P4主机租用799元/月.月付免压金
站内搜索
文章页数:[1] 
这次在项目中,用到了大文件上传,要上传的文件有100多m,于是研究现在国内使用的大文件上传的
组件发现用的比较多的有两个控件aspnetupload 2.0和lion.web.uploadmodule,另外还有思归在它的博客
堂中所说的办法 http://blog.joycode.com/saucer/archive/2004/03/16/16225.aspx
两个控件的方法是:利用隐含的httpworkerrequest,用它的getpreloadedentitybody 和 readentitybody方法从iis为asp.net建立的pipe里分块读取数据。chris hynes为我们提供了这样的一个方案(用httpmodule),该方案除了允许你上传大文件外,还能实时显示上传进度。
lion.web.uploadmodule和aspnetupload 两个.net组件都是利用的这个方案。
当上传单文件时,两个软件的方法是一样的,继承httpmodule
httpapplication application1 = sender as httpapplication;
httpworkerrequest request1 = (httpworkerrequest) ((iserviceprovider) httpcontext.current).getservice(typeof(httpworkerrequest));
try
{
if (application1.context.request.contenttype.indexof("multipart/form-data") <= -1)
{
return;
}
//check the hasentitybody
if (!request1.hasentitybody())
{
return;
}

int num1 = 0;
timespan span1 = datetime.now.subtract(this.begintime);

string text1 = application1.context.request.contenttype.tolower();

byte[] buffer1 = encoding.ascii.getbytes(("\r\n--" + text1.substring(text1.indexof("boundary=") + 9)).tochararray());
int num2 = convert.toint32(request1.getknownrequestheader(11));
progress progress1 = new progress();

application1.context.items.add("filelist", new hashtable());

byte[] buffer2 = request1.getpreloadedentitybody();
num1 += buffer2.length;

string text2 = this.analysepreloadedentitybody(buffer2, "uploadguid");
if (text2 != string.empty)
{
application1.context.items.add("lionsky_uploadmodule_uploadguid", text2);
}
bool flag1 = true;
if ((num2 > this.uploadfilelength()) && ((0 > span1.totalhours) || (span1.totalhours > 3)))
{
flag1 = false;
}
if ((0 > span1.totalhours) || (span1.totalhours > 3))
{
flag1 = false;
}
string text3 = this.analysepreloadedentitybody(buffer2, "uploadfolder");
arraylist list1 = new arraylist();
requeststream stream1 = new requeststream(buffer2, buffer1, null, requeststream.filestatus.close, requeststream.readstatus.noread, text3, flag1, application1.context, string.empty);
list1.addrange(stream1.readbody);
if (text2 != string.empty)
{
progress1.filelength = num2;
progress1.receivedlength = num1;
progress1.filename = stream1.originalfilename;
progress1.filecount = ((hashtable) application1.context.items["filelist"]).count;
application1.application["_uploadguid_" + text2] = progress1;
}
if (!request1.isentireentitybodyispreloaded())
{
byte[] buffer4;
arraylist list2;
int num3 = 204800;
byte[] buffer3 = new byte[num3];
while ((num2 - num1) >= num3)
{
if (!application1.context.response.isclientconnected)
{
this.clearapplication(application1);
}
num3 = request1.readentitybody(buffer3, buffer3.length);
num1 += num3;
list2 = stream1.contentbody;
if (list2.count > 0)
{
buffer4 = new byte[list2.count + buffer3.length];
list2.copyto(buffer4, 0);
buffer3.copyto(buffer4, list2.count);
stream1 = new requeststream(buffer4, buffer1, stream1.filestream, stream1.fstatus, stream1.rstatus, text3, flag1, application1.context, stream1.originalfilename);
}
else
{
stream1 = new requeststream(buffer3, buffer1, stream1.filestream, stream1.fstatus, stream1.rstatus, text3, flag1, application1.context, stream1.originalfilename);
}
list1.addrange(stream1.readbody);
if (text2 != string.empty)
{
progress1.receivedlength = num1;
progress1.filename = stream1.originalfilename;
progress1.filecount = ((hashtable) application1.context.items["filelist"]).count;
application1.application["_uploadguid_" + text2] = progress1;
}
}
buffer3 = new byte[num2 - num1];
if (!application1.context.response.isclientconnected && (stream1.fstatus == requeststream.filestatus.open))
{
this.clearapplication(application1);
}
num3 = request1.readentitybody(buffer3, buffer3.length);
list2 = stream1.contentbody;
if (list2.count > 0)
{
buffer4 = new byte[list2.count + buffer3.length];
list2.copyto(buffer4, 0);
buffer3.copyto(buffer4, list2.count);
stream1 = new requeststream(buffer4, buffer1, stream1.filestream, stream1.fstatus, stream1.rstatus, text3, flag1, application1.context, stream1.originalfilename);
}
else
{
stream1 = new requeststream(buffer3, buffer1, stream1.filestream, stream1.fstatus, stream1.rstatus, text3, flag1, application1.context, stream1.originalfilename);
}
list1.addrange(stream1.readbody);
if (text2 != string.empty)
{
progress1.receivedlength = num1 + buffer3.length;
progress1.filename = stream1.originalfilename;
progress1.filecount = ((hashtable) application1.context.items["filelist"]).count;
if (flag1)
{
progress1.uploadstatus = progress.uploadstatusenum.uploaded;
}
else
{
application1.application.remove("_uploadguid_" + text2);
}
}
}
byte[] buffer5 = new byte[list1.count];
list1.copyto(buffer5);
this.populaterequestdata(request1, buffer5);
}
catch (exception exception1)
{
this.clearapplication(application1);
throw exception1;
}


而思归所说的方法使用mime也能上传大文件,在以下地址下载
http://krystalware.com/files/slickupload.zip
不过觉得的思归的方法容易很多






文章整理:站长天空 网址:http://www.z6688.com/
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

文章页数:[1] 


放大字体显示 缩小字体显示 打印文章 推荐给朋友
热门文章
·VisualC#中MDI窗体初步-.NET教程,C#语言
·2004年全国计算机等级考试二级vb全真上机试题解析
·全国计算机等级考试一级ms office考试(样题)
·java生成JPEG 图像文件-JSP教程,Java技巧及代码
·全国计算机等级考试二级access考试大纲
·全国计算机等级考试一级b考试大纲
·大文件上传研究-ASP教程,ASP应用
·全国计算机等级考试二级c语言考试大纲
·C#字符串的使用笔记-.NET教程,C#语言
·c#实现类似于SqlServer视图设计器的可浮动窗体-.NET教程,C#语言
最新文章
·利用c#远程存取access数据库_c#应用
·dreamweaver简单描述制作网页的基本步骤_dreamweaver教程
·fireworks制作波普网点画面特效_fireworks教程
·如何提高垃圾站点gg ad广告单元点击价格_网赚技巧
·谈百度联盟和google adsense广告的均衡优化_网赚技巧
·google adsense 广告功略之三定理_网赚技巧
·为什么网站要先做小众_站长心得
·针对地方门户网站运营推广的经验分析_站长心得
·如何做网站的搜索引擎优化?_站长心得
·如何正规的快速建立赚钱的网站_google推广
相关主题
西部数码虚拟主机

友情链接
CNNIC 西部数码
万网 自助建站
虚拟主机 asp空间
域名注册 域名
域名申请 主页空间
论坛空间 网站空间
国际域名 虚拟空间
空间租用 DDOS防火墙
成都主机托管 四川主机托管
主机租用 服务器租用
网站目录 自助建站
虚拟主机 网址大全
软件下载
自助链接
虚拟主机资讯 特价虚拟主机
版权申明:本站文章均来自网络,如有侵权,请联系我们,我们收到后立即删除,谢谢!
关于我们:站长天空:专业提供最新的站长资讯、在线教程、虚拟主机权威评测、虚拟主机性能对比、网站制作教程,开发教程,站长工具。包括网页制作教程、冲浪宝典、编程参考、操作系统、软件教学、行业动态等。
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有。
发表评论 打印  刷新     关闭