2016-10-27 69 views
2

進出口使用的懸浮窗JS(http://www.dropzonejs.com/)上傳文件,但我需要知道有多少文件是當前的懸浮窗內,用戶可能已經刪除了一些,但我需要在提交用戶填寫的整個表單之前,要知道是否至少有1個文件。懸浮窗JS,找出有多少文件正在懸浮窗內

如果我使用myDropzone.length,它仍會計算從dropzone中刪除的文件,所以如果用戶添加2個文件,然後刪除其中的一個,.length將= 2,在這種情況下,我需要知道這將在這種特殊情況下

+2

的可能的複製[獲取在懸浮窗中選擇的文件的數量(http://stackoverflow.com/questions/29910240/get-count-of-selected-files-in-dropzone) –

回答

3

是1的實際長度「要訪問的所有文件,在懸浮窗,使用myDropzone.files。」

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

+1

問題是當用戶決定刪除這些文件之一,那麼。長度保持不變計數刪除的文件,所以我需要知道有多少文件,而不刪除那些 – ajeleandro

2

懸浮窗提供了多種功能,只得到接受,拒絕,排隊或上傳文件。

// 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 
+0

我試圖讓那些在文件列表在那裏Dropzone。如何訪問Dropzone中的文件列表? – user1794918

+0

@ user1794918使用'myDropzone.files'。刪除上面例子的'.lenght',你可以得到每個部分的文件列表 – Camille