jQuery File Upload显示剩余时间? [英] jQuery File Upload show time remaining?
问题描述
我正在使用 jQuery文件上传
一切正常,我正在向用户显示一个进度条,其中显示了如下所示的上传进度:
It is working fine and I am showing the user a progress bar showing upload progress with code like the below:
$('#fileupload').fileupload({
/* ... */
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#progress .bar').css(
'width',
progress + '%'
);
}
});
在我的页面上,我目前仅包含了jquery.fileupload.js文件.在progressall函数的数据中,我可以看到比特率,总文件大小和当前加载的数据,正如我所说的,它们可以按预期更新进度条.但是,在网站上阅读此链接时,它表明我可以获得包括剩余时间在内的更多信息吗?我一直无法使它正常工作.还有一个jquery.fileupload-ui.js文件-我尝试在jquery.fileupload.js之后添加该文件,但是我没有看到剩余时间的属性被添加到progressall函数中的数据中.我还尝试删除jquery.fileupload.js,仅包含jquery.fileupload-ui.js,但是这破坏了我的文件上传,并且无法正常工作.
On my page I have just included the jquery.fileupload.js file currently. Within the data of the progressall function I can see the bitrate, the total file size and the data loaded currently, which as I say updates my progress bar as expected. However reading this link on the site it suggests that I can get extra information including the time remaining? I have been unable to get this working however. There is a jquery.fileupload-ui.js file as well - I tried including that after my jquery.fileupload.js but I did not see time remaining propety getting added to the data in the progressall function. I also tried removing jquery.fileupload.js and just included jquery.fileupload-ui.js however that broke my file upload and it did not function.
无论如何,我是否可以使用加载的比特率/数据和总大小轻松地计算出剩余时间,或者有人建议我从插件中直接获取此扩展信息的正确方法?
Is there anyway I could easily calculate the time remaining using the bit rate/data loaded and total size or has anyone got a suggestion of the correct way I should be getting this extended information out of the box from the plugin?
推荐答案
以扩展进度信息为例,尝试...
Given the example of Extended Progress Information, try ...
$('#fileupload').bind('fileuploadprogress', function (e, data) {
// Log the current bitrate for this upload:
// console.log(data.bitrate);
console.log(data);
});
...检查通过此数据点报告的数据.然后,您可以访问所需的内容.
... to examine what data is being reported via this data point. Then, you can access what you need.
这篇关于jQuery File Upload显示剩余时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!