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 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化