最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Dropzone Js, find out how many files are currently inside the dropzone - Stack Overflow

programmeradmin3浏览0评论

Im using the dropzone js (/) to upload files but I need to know how many files are currently inside the Dropzone, the user might have deleted some but I need to know if there is at least 1 file before I submit the whole form that the user is filling.

If i use the myDropzone.length it will still count the removed files from the dropzone so if the user adds 2 files and then removes one of them the .length would be = 2 and in that case I would need to know the real length which would be 1 in this particular case

Im using the dropzone js (http://www.dropzonejs.com/) to upload files but I need to know how many files are currently inside the Dropzone, the user might have deleted some but I need to know if there is at least 1 file before I submit the whole form that the user is filling.

If i use the myDropzone.length it will still count the removed files from the dropzone so if the user adds 2 files and then removes one of them the .length would be = 2 and in that case I would need to know the real length which would be 1 in this particular case

Share Improve this question edited Oct 28, 2016 at 15:59 ajeleandro asked Oct 27, 2016 at 20:39 ajeleandroajeleandro 1011 gold badge1 silver badge6 bronze badges 1
  • 2 Possible duplicate of Get count of selected files in dropzone – I wrestled a bear once. Commented Oct 27, 2016 at 20:50
Add a comment  | 

2 Answers 2

Reset to default 18

Dropzone provide multiple function to get only accepted, rejected, queued or uploading files.

// To access only accepted files count (answer of question)
myDropzone.getAcceptedFiles().length


// To access all files count
myDropzone.files.length
// To access all rejected files count
myDropzone.getRejectedFiles().length
// To access all queued files count
myDropzone.getQueuedFiles().length
// To access all uploading files count
myDropzone.getUploadingFiles().length

Get from document API here

"To access all files in the dropzone, use myDropzone.files."

http://www.dropzonejs.com/#dropzone-methods

发布评论

评论列表(0)

  1. 暂无评论