【问题标题】:Dropzone.js and full path for each fileDropzone.js 和每个文件的完整路径
【发布时间】:2015-01-28 19:26:03
【问题描述】:

我正在尝试使用 Dropzone.js 重新创建已删除文件/文件夹的文件夹结构。 有没有办法可以访问每个文件的完整路径,以便在php端重新创建目录结构?

【问题讨论】:

    标签: dropzone.js


    【解决方案1】:

    这是一种简单的方法,您可以另外发送某些文件夹中所有文件的完整路径:

    dropzone.on("sending", function(file, xhr, data) {
    
        // if file is actually a folder
        if(file.fullPath){
            data.append("fullPath", file.fullPath);
        }
    });
    

    【讨论】:

    • 为什么要投反对票?这是正确的答案。当 dropzone.js 在 chrome 浏览器上运行时,webkitGetAsEntry 可用,最终 Dropzone.prototype._addFilesFromDirectory 被称为“文件”可以定义“fullPath”。因此浏览器可以发送每个文件的路径信息。
    • 赞成 -- 非常感谢你提供这个有用的 sn-p 代码!!!
    【解决方案2】:

    你可以使用文件阅读器,我是在 Angular 5 中完成的:

     onFilesAdded(files: File[]) {
    console.log(files);
    this.dropzone.reset();
    files.forEach(file => {
    
      const reader = new FileReader();
      let content;
      reader.onload = (e: ProgressEvent) => {
        content = (e.target as FileReader).result;
        console.log(content);
      };
      this.previewImage(file).then(response => {
        const imageItem = new FileItem(
          response,
          content,
        );
        let imagesComponentItems = this.store.value.imagesComponentItems;
        imagesComponentItems = [...imagesComponentItems, imageItem];
        this.store.set("imagesComponentItems", imagesComponentItems);
        this.hasImages();
      });
    });
    

    }

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-22
      • 1970-01-01
      • 2014-12-21
      • 1970-01-01
      相关资源
      最近更新 更多