300分求助!!!JSP文件上传,实时显示上穿进度及状态的方法!!急!!!! http://www.tongyi.net/article/20011127/200111272695.shtml去看看,对你可能有帮助! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 晕~~那是上传啊GG~~不过,还是谢谢你UP!! 我这里有原来ASP的希望对你有帮助<html><body> <script language="javascript"><!--theUniqueID = (new Date()).getTime() % 1000000000;function s() //让数据提交的同时执行显示进度条的函数{ bar(); //开始执行反映上传情况的函数 document.myform.action = "progressupload.asp?ID=" + theUniqueID; //处理上传数据的程序 document.myform.target="up" //将提交的数据放在一个名字是up隐藏的iframe里面处理,这样提交的页面就不会跳转到处理数据的页 document.myform.submit(); //提交表单 }function bar(){ bar1.style.display=''; //让显示上传进度显示的层的可见 var timeoutid=null; //这个变量是作定时器的ID var oXMLDoc = new ActiveXObject('MSXML'); //创建'MSXML'对象 sURL = "progressbar.asp?ID=" + theUniqueID + "&temp="+Math.random(); //获取上传状态数据的地址 oXMLDoc.url = sURL; //load数据 var oRoot=oXMLDoc.root; //获取返回xml数据的根节点 if(oRoot.children != null) { if (oRoot.children.item(0).text-100==0) //文件上传结束就取消定时器 clearTimeout(timeoutid) PercentDone.style.width=oRoot.children.item(0).text+"%"; //设置进度条的百分比例 //根据返回的数据在客户端显示 min.innerHTML=oRoot.children.item(1).text; //显示剩余时间(分钟) secs.innerHTML=oRoot.children.item(2).text; //显示剩余时间(秒钟) BytesDone.innerHTML=oRoot.children.item(3).text; //已上传数据大小 BytesTotal.innerHTML=oRoot.children.item(4).text; //总大小 BytesPerSecond.innerHTML=oRoot.children.item(5).text; //传输速率 Information.innerHTML=oRoot.children.item(6).text; //上传信息 } if (oRoot.children.item(0).text-100<0) //只要文件没有传完,就每隔多少时间获取一次数据 timeoutid = setTimeout("bar()",50) //这里设定时间间隔是0.05秒,你也可以根据你的情况修改获取数据时间间隔}//--></script> <form name="myform" method="post" action="progressupload.asp" enctype="multipart/form-data" target=up><input type="file" name="filefield1"><br><input type="button" name="dosubmit" value="Upload" onclick="s()"><br><div id=bar1 style="display:none"><table border="0" width="100%"> <tr> <td><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><b>传送:</b></font></td> </tr> <tr bgcolor="#999999"> <td> <table border="0" width="" cellspacing="1" bgcolor="#0033FF" id=PercentDone> <tr> <td><font size=1> </font></td> </tr> </table> </td> </tr> <tr> <td> <table border="0" width="100%"> <tr> <td><font face="Verdana, Arial, Helvetica, sans-serif" size="1">剩余时间:</font></td> <td><font face="Verdana, Arial, Helvetica, sans-serif" size="1"> <span id=min></span> 分 <span id=secs></span> 秒 (<span id=BytesDone></span> KB of <span id=BytesTotal></span> KB 已上传)</font></td> </tr> <tr> <td><font face="Verdana, Arial, Helvetica, sans-serif" size="1"> 传送速度:</font></td> <td><font face="Verdana, Arial, Helvetica, sans-serif" size="1"> <span id=BytesPerSecond></span> KB/秒</font></td> </tr> <tr> <td><font face="Verdana, Arial, Helvetica, sans-serif" size="1">信息:</font></td> <td><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><span id=Information></span></font></td> </tr> </table> </td> </tr> <tr></tr></table></div><iframe name="up" style="display:none"></iframe></form> </body></html> progressbar.asp(返回上传状况数据的文件) <%@EnableSessionState=False%><%On Error Resume NextSet theProgress = Server.CreateObject("ABCUpload4.XProgress") '创建上传组件对象theProgress.ID = Request.QueryString("ID")'将返回数据以xml格式输出%><?xml version="1.0" encoding="gb2312" ?><plan> <PercentDone><%=theProgress.PercentDone%></PercentDone> <min><%=Int(theProgress.SecondsLeft/60)%></min> <secs><%=theProgress.SecondsLeft Mod 60%></secs> <BytesDone><%=Round(theProgress.BytesDone / 1024, 1)%></BytesDone> <BytesTotal><%=Round(theProgress.BytesTotal / 1024, 1)%></BytesTotal> <BytesPerSecond><%=Round(theProgress.BytesPerSecond/1024, 1)%></BytesPerSecond> <Information><%=theProgress.Note%></Information></plan>progressupload.asp(处理上传文件)<%@EnableSessionState=False%> <%Response.Expires = -10000Server.ScriptTimeOut = 300 Set theForm = Server.CreateObject("ABCUpload4.XForm")theForm.Overwrite = TruetheForm.MaxUploadSize = 8000000theForm.ID = Request.QueryString("ID")Set theField = theForm("filefield1")(1)If theField.FileExists Then theField.Save theField.FileNameEnd If%><html><body>传送结束</body></html>对于其他组件上传,原理也就差不多了,只是方法不一样罢了。希望大家有什么意见和建议和我联系:) 楼上的~我更晕啊~~~http://www.knowsky.com/list.asp?id=2698我GOOGLE过了~ASP的不少,JSP的没见到啊`~太急了,来不及写~哪位兄弟再帮我想想? KKKKKKKK我也遇到这个问题,谁解决希望通知一下:[email protected]谢谢! 我的天 我怀疑用JSPSMARTUPLOAD能否解决这一问题...我感觉它根本没这功能嘛~ Spring AOP , aspect使用时的思路 问一个前端的问题 关于jstl 取值的问题 讨论下数据库连接池c3p0 hibernate主外键配置 JSP传特殊值问题 新人提问:使用DispatchAction的问题 我的表主索引字段为char型,请问在hibernate中如何插入数据 在jsp里怎么调用这个存储过程得到总数 在JSP中怎样使JavaBean之间互相调用,注意什么? 问一个超级菜的问题(不要笑我) 关于applet的问题 再问JAVA的中文问题
那是上传啊GG~~
不过,还是谢谢你UP!!
希望对你有帮助
<html><body> <script language="javascript"><!--theUniqueID = (new Date()).getTime() % 1000000000;function s() //让数据提交的同时执行显示进度条的函数{ bar(); //开始执行反映上传情况的函数 document.myform.action = "progressupload.asp?ID=" + theUniqueID; //处理上传数据的程序 document.myform.target="up" //将提交的数据放在一个名字是up隐藏的iframe里面处理,这样提交的页面就不会跳转到处理数据的页 document.myform.submit(); //提交表单 }function bar(){ bar1.style.display=''; //让显示上传进度显示的层的可见 var timeoutid=null; //这个变量是作定时器的ID var oXMLDoc = new ActiveXObject('MSXML'); //创建'MSXML'对象 sURL = "progressbar.asp?ID=" + theUniqueID + "&temp="+Math.random(); //获取上传状态数据的地址 oXMLDoc.url = sURL; //load数据 var oRoot=oXMLDoc.root; //获取返回xml数据的根节点 if(oRoot.children != null) { if (oRoot.children.item(0).text-100==0) //文件上传结束就取消定时器 clearTimeout(timeoutid) PercentDone.style.width=oRoot.children.item(0).text+"%"; //设置进度条的百分比例 //根据返回的数据在客户端显示 min.innerHTML=oRoot.children.item(1).text; //显示剩余时间(分钟) secs.innerHTML=oRoot.children.item(2).text; //显示剩余时间(秒钟) BytesDone.innerHTML=oRoot.children.item(3).text; //已上传数据大小 BytesTotal.innerHTML=oRoot.children.item(4).text; //总大小 BytesPerSecond.innerHTML=oRoot.children.item(5).text; //传输速率 Information.innerHTML=oRoot.children.item(6).text; //上传信息 } if (oRoot.children.item(0).text-100<0) //只要文件没有传完,就每隔多少时间获取一次数据 timeoutid = setTimeout("bar()",50) //这里设定时间间隔是0.05秒,你也可以根据你的情况修改获取数据时间间隔}//--></script> <form name="myform" method="post" action="progressupload.asp" enctype="multipart/form-data" target=up><input type="file" name="filefield1"><br><input type="button" name="dosubmit" value="Upload" onclick="s()"><br><div id=bar1 style="display:none"><table border="0" width="100%"> <tr> <td><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><b>传送:</b></font></td> </tr> <tr bgcolor="#999999"> <td> <table border="0" width="" cellspacing="1" bgcolor="#0033FF" id=PercentDone> <tr> <td><font size=1> </font></td> </tr> </table> </td> </tr> <tr> <td> <table border="0" width="100%"> <tr> <td><font face="Verdana, Arial, Helvetica, sans-serif" size="1">剩余时间:</font></td> <td><font face="Verdana, Arial, Helvetica, sans-serif" size="1"> <span id=min></span> 分 <span id=secs></span> 秒 (<span id=BytesDone></span> KB of <span id=BytesTotal></span> KB 已上传)</font></td> </tr> <tr> <td><font face="Verdana, Arial, Helvetica, sans-serif" size="1"> 传送速度:</font></td> <td><font face="Verdana, Arial, Helvetica, sans-serif" size="1"> <span id=BytesPerSecond></span> KB/秒</font></td> </tr> <tr> <td><font face="Verdana, Arial, Helvetica, sans-serif" size="1">信息:</font></td> <td><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><span id=Information></span></font></td> </tr> </table> </td> </tr> <tr></tr></table></div><iframe name="up" style="display:none"></iframe></form> </body></html> progressbar.asp(返回上传状况数据的文件) <%@EnableSessionState=False%><%On Error Resume NextSet theProgress = Server.CreateObject("ABCUpload4.XProgress") '创建上传组件对象theProgress.ID = Request.QueryString("ID")'将返回数据以xml格式输出%><?xml version="1.0" encoding="gb2312" ?><plan> <PercentDone><%=theProgress.PercentDone%></PercentDone> <min><%=Int(theProgress.SecondsLeft/60)%></min> <secs><%=theProgress.SecondsLeft Mod 60%></secs> <BytesDone><%=Round(theProgress.BytesDone / 1024, 1)%></BytesDone> <BytesTotal><%=Round(theProgress.BytesTotal / 1024, 1)%></BytesTotal> <BytesPerSecond><%=Round(theProgress.BytesPerSecond/1024, 1)%></BytesPerSecond> <Information><%=theProgress.Note%></Information></plan>
progressupload.asp(处理上传文件)<%@EnableSessionState=False%> <%Response.Expires = -10000Server.ScriptTimeOut = 300 Set theForm = Server.CreateObject("ABCUpload4.XForm")theForm.Overwrite = TruetheForm.MaxUploadSize = 8000000theForm.ID = Request.QueryString("ID")Set theField = theForm("filefield1")(1)If theField.FileExists Then theField.Save theField.FileNameEnd If%>
<html>
<body>
传送结束
</body>
</html>对于其他组件上传,原理也就差不多了,只是方法不一样罢了。希望大家有什么意见和建议和我联系:)
我更晕啊~~~http://www.knowsky.com/list.asp?id=2698我GOOGLE过了~
ASP的不少,JSP的没见到啊`~
太急了,来不及写~
哪位兄弟再帮我想想?
我也遇到这个问题,
谁解决希望通知一下:
[email protected]
谢谢!