【问题标题】:Dropzone.js v4+ - Display existing files on server with work limiting the number of files and other functionsDropzone.js v4+ - 显示服务器上的现有文件,限制文件数量和其他功能
【发布时间】:2015-10-16 02:34:53
【问题描述】:

如何将服务器上的现有文件添加到具有正确工作所有功能和正确样式的 dropzone?

【问题讨论】:

    标签: javascript dropzone.js


    【解决方案1】:

    我写了一个添加文件的函数:addCustomFile(file, thumbnail_url, response)

    Powered by 版本:4.0.1 stable

    正确工作:maxFiles 限制、事件 maxfilesexceeded、事件成功等

    $("#dropzone-images").dropzone({
        url: "...",
        paramName: 'image_temp',
        maxFiles: 1,
        init: function () {
            this.addCustomFile = function(file, thumbnail_url , responce){
                // Push file to collection
                this.files.push(file);
                // Emulate event to create interface
                this.emit("addedfile", file);
                // Add thumbnail url
                this.emit("thumbnail", file, thumbnail_url);
                // Add status processing to file
                this.emit("processing", file);
                // Add status success to file AND RUN EVENT success from responce
                this.emit("success", file, responce , false);
                // Add status complete to file
                this.emit("complete", file);
            }
    
            this.addCustomFile(
                // File options
                {
                    // flag: processing is complete
                    processing: true,
                    // flag: file is accepted (for limiting maxFiles)
                    accepted: true,
                    // name of file on page
                    name: "The name",
                    // image size
                    size: 12345,
                    // image type
                    type: 'image/jpeg',
                    // flag: status upload
                    status: Dropzone.SUCCESS
                },
                // Thumbnail url
                "http://.../img.jpg",
                // Custom responce for event success
                {
                    status: "success"
                }
            );
        }
    });
    

    【讨论】:

    • 虽然这很好用......当页面第一次加载时,在图像上看到十几个飞行的复选标记非常烦人。我一直在努力让它不显示像这样显示的已上传图像的飞行“dz-success-mark”。
    猜你喜欢
    • 2014-07-23
    • 1970-01-01
    • 2013-08-05
    • 2020-07-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-15
    相关资源
    最近更新 更多