DropZone acceptedFiles类型过滤器 [英] DropZone acceptedFiles type filter
问题描述
我有一个 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屋!