【问题标题】:Pass files from input-element to plupload (Add folder)将文件从输入元素传递到 plupload(添加文件夹)
【发布时间】:2020-01-02 05:45:03
【问题描述】:

我想上传一个文件夹的所有文件。由于 plupload 不提供此功能,因此我有这样的输入

<input type="file" name="files[]" id="files" multiple directory="" webkitdirectory="" mozdirectory="">

存储所选文件夹中的所有文件。我现在想将这些加载到我的上传器

uploader = new plupload.Uploader({});

当我尝试这样做时

$('#files').change(function (){
    if ($(this).prop('files').length > 0)
    {
        uploader.addFile($('#files').prop('files')[0]);
    }
});

结果

Uncaught TypeError: Cannot read property 'processing' of null

uploader.start();

如何将文件引用从我的输入元素传递到 plupload-Uploader?

【问题讨论】:

  • 您是否要上传所选文件夹中的所有文件?
  • @JenuelGanawed 是的,我选择一个文件夹,然后上传它包含的所有文件。这里的重点是我不想自己选择文件,plupload 不提供 webkitdirectory 支持

标签: javascript jquery plupload


【解决方案1】:

我在这里找到了解决方法。一个通过jQuery设置plupload输入元素的文件并触发onChange使其工作。

$('#html5_plupload-HASH').prop('files', $('#files').get(0).files).change();

我还发现根据他们的list of supported features,plupload 实际上在版本 2 中提供了对 webkitdirectory 的支持。有一个名为select_folder 的参数,但我现在无法让它工作。

也可以只在plupload.full(.min).js中找到input-element并添加webkitdirectory属性。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-04-13
    • 2020-08-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-18
    • 2015-05-23
    • 2021-09-29
    相关资源
    最近更新 更多