DropZone acceptedFiles类型过滤器 [英] DropZone acceptedFiles type filter

查看:384
本文介绍了DropZone acceptedFiles类型过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 DropZone 表单,除了一个例外,它工作得很好,我似乎无法精确地限制文件类型根据我的需要。

I've got a DropZone form working perfectly with one exception, I can't seem to limit the file types as precisely as I need to.

使用 acceptedFiles: image / * 将所有不是图像的文件夹和文件类型变暗。但是包含了 TIFF ,我需要将其缩小为 JPG PNG 。许多尝试和错误并没有使我到达那里。

Using acceptedFiles: "image/*" dims all folders and file types that are not images, as it should. TIFF is included though and I need to reduce it to exclusively JPG and PNG. A lot of trial and error has not gotten me there.

我尝试过的事情:

acceptedFiles: "image/jpg"
acceptedFiles: ".jpeg,.jpg,.png"
acceptedFiles: "image/jpg,png"

但是它们都使所有内容都可以选择。

But they all make everything selectable.

的正确格式是什么> JPG PNG

推荐答案

更多的反复试验最终解决了该问题:

More trial and error eventually turned up the solution:

Dropzone.options.dzone = {
acceptedFiles: "image/jpeg,image/png,image/gif"
}

显然,我的错误主要是使用jpg,这使所有操作均失败。上面的工作就像一种魅力。

Apparently my error was primarily in using jpg which made it all fail. The above works like a charm.

这篇关于DropZone acceptedFiles类型过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆