Dropzone.js event after drop end and before uploading

Dropzone.js event after drop end and before uploading

本文关键字:and before uploading end drop js event after Dropzone      更新时间:2023-09-26

我正在寻找一个dropzone.js事件,该事件在放置结束后和上传之前引发。

我需要的是一次访问有关丢弃文件的所有信息,而不是逐个文件访问,因此addedfile事件不是一个选项。

我认为dragend事件是合适的,但当我将文件放入dropzone时,它并没有被触发。

我使用的代码片段如下所示:

Dropzone.options.myDropzone = {
    // Prevents Dropzone from uploading dropped files immediately
    autoProcessQueue : false,
    dictDefaultMessage: "Drop files or click here to upload a new DICOM series ...",
    init : function() {
        myDropzone = this;
        //Restore initial message when queue has been completed
        this.on("dragend", function(file) {
            console.log("ondragend");            
        });
    }

};

我是不是错过了什么?dropzone.js中是否存在其他用于此目的的事件?

有一个名为addedfiles的事件,它将在两个"拖放";以及手动文件选择。

this.on("addedfiles", function(files) {
     console.log(files.length + ' files added');
});

如果您想对drop事件进行回调,则应该使用"drop"。在该事件中,请查看"files"数组。但请注意,如果用户单击dropzone并从中选择文件,则不会触发此事件。

Dropzone.options.MyDropzone = {
    autoProcessQueue : false,
    dictDefaultMessage: "Drop files or click here to upload a new DICOM series ...",
    init : function() {
        myDropzone = this;
        //Restore initial message when queue has been completed
        this.on("drop", function(event) {
            console.log(myDropzone.files);            
        });
    }
};

例如,请参阅此fiddle:jsfiddle.net/qqkbzv5a/2/

最后我使用了selectedfiles事件,它响应dropzone的drop和click操作。

 this.on("selectedfiles", function(listFiles) {
            cont_files = listFiles.length;
        });