简体   繁体   English

Jquery 文件上传 - 获取上传的附件数量

[英]Jquery file upload - get number of attachments uploaded

I'm currently using the Jquery plugin for file uploads: Jquery File Upload我目前正在使用 Jquery 插件进行文件上传: Jquery 文件上传

However, nowhere in the documentation does it specify how to get the number of current uploaded files.但是,文档中没有任何地方指定如何获取当前上传文件的数量。 It would be nice to query the plugin to check how many have been uploaded.最好查询插件以检查已上传的数量。 Is there any way to do this?有没有办法做到这一点?

data.files.length

Take a look at the documentation on send .查看send上的文档。

You can implement a counter and increment it on send .您可以实现一个计数器并在send时增加它。
The number of files uploaded will equal send - 1 .上传的文件数将等于send - 1

I came up with this answer.我想出了这个答案。 The problem with the send callback is that it doesn't indicate successful upload.发送回调的问题在于它并不表示上传成功。 I tried 'done' instead but that doesn't handle the situation where there are deleted uploads.我尝试“完成”,但这并不能处理删除上传的情况。

Instead I count the number of successful templates within the control.相反,我计算控件中成功模板的数量。 Eg例如

$("#fileupload .template-download:not('.ui-state-error')").length;    

I call this on the 'done' callback to refresh the upload count.我在“完成”回调中调用它来刷新上传计数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM