I'm using Dropzone to do a image check and tell the user if the resolution is good enough for production.
我正在使用Dropzone进行图像检查,并告诉用户分辨率是否足以进行生产。
When files are in RAW format (dng, cr2, orf, etc), I want them to be automatically APPROVED (as if they where uploaded) but WITHOUT actually uploading them (RAW files are large and would take too long to upload).
当文件是RAW格式(dng,cr2,orf等)时,我希望它们被自动批准(好像它们已经上传)但没有实际上传它们(RAW文件很大,上传时间太长)。
Basically what I mean is that the file would stay in the list with a check-mark but would not be sent to php. Is this possible?
基本上我的意思是文件将留在列表中带有复选标记但不会发送到php。这可能吗?
Currently I'm trying to refuse those files based on their type and then programmatically change them to "success". But I can't seem to find how.
目前我正在尝试根据其类型拒绝这些文件,然后以编程方式将其更改为“成功”。但我似乎无法找到如何。
var counter = 0;
myDropzone.on("sending", function(file) {
if(file.type == "image/cr2"){
myDropzone.files[counter].accepted = false;
}
counter++;
});
1 个解决方案
#1
0
I don't think dropzone is going to identify the file type of those formats, but you can check if the filename contains the extension you want, here an example:
我不认为dropzone会识别这些格式的文件类型,但你可以检查文件名是否包含你想要的扩展名,这里有一个例子:
var formats = ['.orf', '.cr2', '.dng'];
Dropzone.autoDiscover = false;
var myDropzone = $('#yourDropzoneId').dropzone({
accept: function (file, done) {
var extension = '.' + file.name.toLowerCase().split('.').slice(-1)[0];
if (formats.indexOf(extension) >= 0) {
done('OK');
$('.dz-preview').last().toggleClass('dz-error dz-success');
}
else {
done();
}
}
});
In this example the files with a extension specified in the array will be rejected but then is going to simulate a success, the other files with a different extension will be uploaded.
在此示例中,将拒绝具有在数组中指定的扩展名的文件,但随后将模拟成功,将上载具有不同扩展名的其他文件。
#1
0
I don't think dropzone is going to identify the file type of those formats, but you can check if the filename contains the extension you want, here an example:
我不认为dropzone会识别这些格式的文件类型,但你可以检查文件名是否包含你想要的扩展名,这里有一个例子:
var formats = ['.orf', '.cr2', '.dng'];
Dropzone.autoDiscover = false;
var myDropzone = $('#yourDropzoneId').dropzone({
accept: function (file, done) {
var extension = '.' + file.name.toLowerCase().split('.').slice(-1)[0];
if (formats.indexOf(extension) >= 0) {
done('OK');
$('.dz-preview').last().toggleClass('dz-error dz-success');
}
else {
done();
}
}
});
In this example the files with a extension specified in the array will be rejected but then is going to simulate a success, the other files with a different extension will be uploaded.
在此示例中,将拒绝具有在数组中指定的扩展名的文件,但随后将模拟成功,将上载具有不同扩展名的其他文件。