dpuwov1487 2015-08-08 13:01
浏览 208
已采纳

如何添加之前加载到DropZone.js的文件

Got a really interesting (for me) problem.

I have a dropzone.js plugin installed and now I need to put some files there... from php.

What I am trying to do:

  1. php script detects, that there are some files (in directory) that were loaded earlier (for example, few days ago). (I know the names of this files).

  2. After that, I have to pass this files to my javascript script which will add them to dropzone so user could see files that he uploaded earlier.

And all of this using Ajax.

I understand, what to do with step 1 (I can find those files). But how to pass it to js and then add to dropzone?

Or am I thinking wrong? Help me please.

  • 写回答

1条回答 默认 最新

  • dsfds2353 2015-08-10 20:34
    关注

    Dropzone has a wiki page explaining that.

    Here is how I've recently done that by getting file URLs from REST API:

    $.get('http://api.to.return.files', function(data) {
        $(data.photos).each(function(i, photo) {
            var mockFile = { name: photo.name, size: photo.size, accepted: true, id: photo.id };
    
            myDropzone.emit("addedfile", mockFile);
            myDropzone.emit("thumbnail", mockFile, photo.url);
            myDropzone.emit("complete", mockFile);
            myDropzone.files.push(mockFile);
        });
    });
    

    If you already have your files urls in the script, use them instead of API response in my case.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 怀疑手机被监控,请问怎么解决和防止
  • ¥15 Qt下使用tcp获取数据的详细操作
  • ¥15 idea右下角设置编码是灰色的
  • ¥15 全志H618ROM新增分区
  • ¥15 在grasshopper里DrawViewportWires更改预览后,禁用电池仍然显示
  • ¥15 NAO机器人的录音程序保存问题
  • ¥15 C#读写EXCEL文件,不同编译
  • ¥15 MapReduce结果输出到HBase,一直连接不上MySQL
  • ¥15 扩散模型sd.webui使用时报错“Nonetype”
  • ¥15 stm32流水灯+呼吸灯+外部中断按键