Search code examples
jqueryvalidationfine-uploader

Fine-Uploader - Validation "specific" for each Drag and Drop element


Dealing with Fine Uploader for the past 2 weeks, I see from the documentation that there is a "validation" option for the "extraButtons" option for Fine Uploader. This is great, as I can limit certain buttons to allow only certain extensions.

However, I was wondering if there is validation implemented for the "dragAndDrop.extraDropzones" option.

I don't see it in the documentation, and I tried to do a few things that I thought might work by accident, but no luck at last.

Your help is greatly appreciated.

Thanks!

Cheers, Thomas

Update

Just to let you see what I've been up to so far, here's the code I have so far: http://jsfiddle.net/beamstyle_thomas/fyp5dqwt/5/

I'm only allowing JPG files to go through for button clicks:

extraButtons: [
{
    element: $('.file-trigger')[0],
    validation: {
        allowedExtensions: ["jpg"]
    }
},

But I don't know how to limit drag and drops... this is what I have:

dragAndDrop: {
    extraDropzones: [ $('.file-trigger') ]
},

A few notes here for you to test: - Try to click on "Test 1", select a non-jpg file. It will cause a validation error because I'm only allowing "jpg" files. - Then, try to drag a non-jpg file (assume you're using Chrome) into "Test 1". It will actually go through because there is no validation currently.

Thanks!


Solution

  • Though other suggestions were valuable, this answer from RayNicholus was the correct one. It was under a comment, so I'm posting this answer here.

    You can examine the qqDropTarget on the File object in your onSubmit handler and reject (return false) if the file is not valid for that particular drop zone.