如何显示HTMl5文件上传进度和文件大小 [英] How to show HTMl5 file upload progress with file size

查看:355
本文介绍了如何显示HTMl5文件上传进度和文件大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我正在显示HTML文件上传进度事件,其中包含%(percentage)......
现在我要显示它的大小为20KB/100KB ...(上传大小)/(总大小)...
在发生事件时,我该怎么办..这是我现在的代码...我应该更改哪些内容,以便在跨度中显示此类格式..

In my application i am showing HTML file upload progress event with %(percentage)...
Now I want to show its like 20KB/100KB...(Uploading Size)/(Total Size)...
In progress event what should i have to do..This is my now code...what should i have to change which will show such format in span ..

  // Update progress bar
xhr.upload.addEventListener("progress", uploadProgress, false);

function uploadProgress(evt) {

   if (evt.lengthComputable) {
      var percentComplete = Math.round(evt.loaded * 100 / evt.total);
				                  
      //for my progrss bar

      $(fileParentDivobj).find("progress").attr(''value'',evt.loaded);
      $(fileParentDivobj).find("progress").attr(''max'',evt.total);
      $(fileParentDivobj).find(".ImgDiv").find("span").html(percentComplete + ''%'');
   }
}//upload progress

推荐答案

(fileParentDivobj).find("progress").attr(``value'',evt.loaded);
(fileParentDivobj).find("progress").attr(''value'',evt.loaded);


(fileParentDivobj).find("progress").attr("max",evt.total);
(fileParentDivobj).find("progress").attr(''max'',evt.total);


(fileParentDivobj).find(.ImgDiv" ).find("span").html(percentComplete +``%''); } }//上传进度
(fileParentDivobj).find(".ImgDiv").find("span").html(percentComplete + ''%''); } }//upload progress


这篇关于如何显示HTMl5文件上传进度和文件大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆