Dropzone.js - Display existing files on server

前端 未结 5 1886
我寻月下人不归
我寻月下人不归 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:44

    I was having trouble with maxFiles/maxfilesexceeded and take some while looking for a anwser and then I found this links below:

    https://www.bountysource.com/issues/1444854-use-files-already-stored-on-server-wiki-example-incomplete?utm_campaign=plugin&utm_content=tracker%2F283989&utm_medium=issues&utm_source=github

    $.each(obj, function(i, item) {
    
      ///faking the BytesSent its not essanail to me.. if you need it just pass the correct one
      var upload = {bytesSent: 12345};
    
      /// again fake the size..
      var mockFile = {name: item.name, size: 12345, accepted: true};
    
      mockFile.upload = upload;
      mockFile.kind = "file";
      Dropzone.forElement("#editfileuploader").emit("addedfile", mockFile);
    
      //push the file to files array because getAcceptedFiles using this array length to get the currct files count..
      Dropzone.forElement("#editfileuploader").files.push(mockFile);
    
      //this for lettig dropzone to creat the thumbnail(item.ts has the file location)
      Dropzone.forElement("#editfileuploader").emit("thumbnail", mockFile, item.ts);
    
      //to show the success mark and to return image id response
      Dropzone.forElement("#editfileuploader").emit("success", mockFile, item.id);
    }); 
    

提交回复
热议问题