Dropzone.js - Display existing files on server

前端 未结 5 1887
我寻月下人不归
我寻月下人不归 2020-12-15 10:04

I\'m currently using dropzone.js v3.10.2 I am having issues displaying my existing files I have already uploaded. I am more than competent with php however I have limited kn

5条回答
  •  情书的邮戳
    2020-12-15 10:27

    For Dropzone 5.x

    The solutions given so far did not work with dropzone version 5.x. What worked for me was to modify dropzone's config options as follows:

    init: function () {
                    var mockFile = {
                        name: 'FileName',
                        size: '1000', 
                        type: 'image/jpeg',
                        accepted: true            // required if using 'MaxFiles' option
                    };
                    this.files.push(mockFile);    // add to files array
                    this.emit("addedfile", mockFile);
                    this.emit("thumbnail", mockFile, 'http://url/to/file');
                    this.emit("complete", mockFile); 
                }
    

    The concept is, to create a mock file, and call the event handlers addedfile and thumbnail to draw the preview. And then finally call on complete event to ensure that there are no progress bars, etc. being displayed.

    Reference

提交回复
热议问题