文件被接受而不排队

Files are Accepted not Queued

使用 DropzoneJS v4.0。

以下是为拖放区设置的选项。

Dropzone.options.myDropzone = {
    acceptedFiles: '.jpg,.jpeg,.png',
    addRemoveLinks: true,
    autoQueue: false,
    clickable: false,
    maxFiles: 1,
    maxThumbnailFilesize: 2000,
    parallelUploads: 10,
    thumbnailWidth: null,
    thumbnailHeight: null,
    init: function() {
        var dropzone = this;

        dropzone.on("addedfile", function(file) {
            if (!file.type.match(/image.*/)) {
                dropzone.removeFile(file);
            }else {
                function();
            }
        });

        dropzone.on("maxfilesexceeded", function(file) {
            dropzone.removeFile(file);
        });

        dropzone.on("removedfile", function(){
            if($('#imgEditor').find('img').length == 0) {
                $('.overlay').remove();
                $('#cropper').remove();
                $('#upload').remove();
            }
        });

        $(document).on('click', '#upload', function(){
            dropzone.processQueue();
        });
    }
};

当我单击从 addedfile 事件中的 function() 动态生成的上传按钮时,没有任何反应。检查 dropzone.getAcceptedFiles().length returns dropzone 中的文件数量,但检查 dropzone.getQueuedFiles().length returns 0. 没有文件已上传或已触发上传且文件类型为有效文件类型。

我需要帮助来理解为什么文件会被视为已接受但未排队。我还没有找到解释差异的文档,如果有的话,在代码中看起来如果文件被接受,它应该被排队,但事实并非如此。所以我知道为什么 processQueue 实际上失败了我只是不知道为什么排队失败。

autoQueue 更改为 true 可以使文件正确上传,但这不是预期的效果。请参阅 Enyo FAQ Dropzone Submit Button

Git #989

autoQueue 就是这样做的:它会在添加文件时将其排队。由于您禁用了它,因此它没有排队。

我认为您正在寻找的是:autoProcessQueue: false 除非您实际处理队列 "manually",否则不会上传文件 "manually"。