如何使用dropzone.js预加载图像

时间:2016-10-29 20:04:42

标签: javascript jquery dropzone.js

我想预先加载一些图片并稍后删除它们。我看了一些教程,但似乎没有用。我的php端是正确的,为了排除故障,我直接引用了我的文件名和大小。仍然一无所获。

如果你知道这件事,请帮助我。谢谢!

Dropzone.options.myAwesomeDropzone  = {

init: function() {
// var thisDropzone = this;

$.get(getPic_url, function(data) {
     $.each(data, function(key,value){ //loop through it

        var mockFile = { name: 'surf-1477342168.jpg', size: 5398538 };    // here we get the file name and size as response 
        Dropzone.options.myAwesomeDropzone.emit("addedfile", mockFile);

// thisDropzone.options.addedfile.call(thisDropzone, mockFile);
// thisDropzone.options.thumbnail.call(thisDropzone, mockFile, "__UPLOAD__/surf-1477342168.jpg");
    });
});
},

1 个答案:

答案 0 :(得分:0)

var mockFile = { name: 'surf-1477342168.jpg', size: 5398538 };

// Call the default addedfile event handler
thisDropzone.emit("addedfile", mockFile);

// And optionally show the thumbnail of the file:
thisDropzone.emit("thumbnail", mockFile, "__UPLOAD__/surf-1477342168.jpg");
},