Dropzone: prevent uploading of duplicate files

前端 未结 4 1025
孤独总比滥情好
孤独总比滥情好 2021-01-04 06:57

I am using Dropzone. I\'d like to prevent the uploading of a file which already exists as thumbnail in Dropzone \"panel\". With uploading I mean not to allow a file with the

4条回答
  •  有刺的猬
    2021-01-04 07:44

    Add these simple lines of code:

    myDropzone.on("addedfile", function(file) {
        if (this.files.length) {
            var _i, _len;
            for (_i = 0, _len = this.files.length; _i < _len - 1; _i++) // -1 to exclude current file
            {
                if(this.files[_i].name === file.name && this.files[_i].size === file.size && this.files[_i].lastModifiedDate.toString() === file.lastModifiedDate.toString())
                {
                    this.removeFile(file);
                }
            }
        }
    });
    

提交回复
热议问题