%Stringpath=request.getContextPath();St"> <%Stringpath=request.getContextPath();St" />
欢迎来到天天文库
浏览记录
ID:6031881
大小:1.02 MB
页数:12页
时间:2017-12-31
《java带进度条的上传文件》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、JSP页面:upload.jsp<%@pagelanguage="java"import="java.util.*"pageEncoding="UTF-8"%><%Stringpath=request.getContextPath();StringbasePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%>
2、4.01Transitional//EN">
3、ruts2ajaxuploadprogress">varover=false;varinter;functionupload(){over=false;$("#s
4、tate").html("")$("#progress").css("width","0")$("input[type=submit]").attr("disabled",true);$("#progress").css("width","0%");$("#state").html("正在上传...总大小:0MB,已上传:0MB,0%,已用时:0秒,剩余时间:0秒,速度:0KB/S");inter=setInterval(req,1000);}functionreq(){//如果上传已经完成if(over){
5、clearInterval(inter);return;}varurl="upload/AjaxServlet";$.get(url,function(date){varstate=date.split("-");$("#state").html("正在上传...总大小:"+state[4]+"MB,已上传:"+state[3]+"MB,"+state[2]+"%,已用时:"+state[0]+"秒,剩余时间:"+state[5]+"秒,速度:"+state[1]+"KB/S");$("#progress")
6、.animate({width:state[2]+"%"},500);if(state[3]==state[4]){over=true;$("input[type=submit]").attr("disabled",false);$("#state").html("上传已完成,总大小:"+state[4]+"MB,已上传:"+state[3]+"MB,"+state[2]+"%,已用时:"+state[0]+"秒,剩余时间:"+state[5]+"秒,速度:"+state[1]+"KB/S");}});}
7、script>
8、0"height="0"frameborder="0">
此文档下载收益归作者所有