Javascript dropzone.js - 选择文件夹进行文件上传

时间:2018-06-05 14:11:12

标签: javascript html file-upload dropzone.js dropzone

我正在使用dropzone.js上传多个文件。 使用此功能,我可以从文件夹中选择多个文件,在选择多个文件时,我只会从列表中选择一组文件。

相反,我需要选择一个文件夹(目录)

我可以拖放文件夹。点击dz-clickable

时我应该做的功能相同

我的Html代码

export LEIN_VERSION="2.7.1

我的Javascript代码

<div class="dropzone dz-clickable" id="myDrop">
    <div class="dz-default dz-message" data-dz-message="">
        <span>Upload or drag your files here</span>
    </div>
</div>

如何选择目录并相应地执行我的流程?任何想法?

3 个答案:

答案 0 :(得分:1)

只需提供@Sri解决方案的上下文

$("div#dropzoneDiv").dropzone({
            url: '/upload',
            init: function() {
                this.hiddenFileInput.setAttribute("webkitdirectory", true);
            }
        });

答案 1 :(得分:0)

我不认为Dropzone.js允许上传整个目录(或者未在其文档中指定)

答案 2 :(得分:0)

让我回答我的问题

通过在webkitdirectory

中将属性true设置为hiddenFileInput来选择文件夹

type属性一起添加

_this3.hiddenFileInput = document.createElement("input");
_this3.hiddenFileInput.setAttribute("type", "file");
_this3.hiddenFileInput.setAttribute("webkitdirectory", true);
相关问题