【问题标题】:Upload an entire folder and not separate files - JS上传整个文件夹而不是单独的文件 - JS
【发布时间】:2019-03-13 18:00:48
【问题描述】:

我有以下问题,我可以逐个文件上传我的照片,但我有以下疑问,有什么方法可以上传包含“n”张图片的文件夹而无需全选?只需单击文件夹并选择它?

在我的例子中,点击文件夹“pasta imagens”。

【问题讨论】:

  • 截至今天,http 不允许这样做。您可以通过压缩和上传。我也不知道你说的是http上传还是使用其他协议。
  • 是的,我使用的是http协议,谢谢你的解释

标签: javascript upload directory


【解决方案1】:

目前无法直接上传文件夹。 但是 Chrome 和 Firefox 提供了一个解决方案,它基本上遍历某个目录中的每个文件并选择它进行上传。

您只需在您的<input type='file'... /> 标签中设置directory 标志(以及供应商前缀的webkitdirectory,以便支持更多种类的浏览器)。

Browser Support

<input type='file' webkitdirectory='' directory='' multiple='true' />

【讨论】:

    猜你喜欢
    • 2010-12-27
    • 2022-01-15
    • 2013-11-24
    • 2017-01-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-10
    相关资源
    最近更新 更多