GeenId
GeenId

Reputation: 85

Jquery Filer Plugin - Adding whitelist extensions

I am using the Jquery Filer plugin for uploading images. Now I want to use a whitelist of only jpg/jpeg images. For using such whitelist there is an option called "extensions", which can hold a {null, Array} as the documentation says.

However, I was not able to get it working. I tried this:

extensions: {
    jpeg: "jpeg",
    jpg: "jpg"
},

and I tried this

extensions: {
    jpeg: "image/jpeg",
    jpg: "image/jpg"
},

But both methods doesn't work because it says Invalid format when trying to upload a .jpg image.

Anyone who can help me to create a whitelist of image-type using the jQuery.Filer plugin?

Repo + documentation https://github.com/CreativeDream/jquery.filer

Upvotes: 0

Views: 524

Answers (1)

Alex McMillan
Alex McMillan

Reputation: 17952

According to the docs:

extensions: Whitelist for file extension. {null, Array}

the extensions option is expecting an array. Try this:

extensions: [
    'jpg',
    'jpeg'
]

but remember this is only filtering by extension - nothing preventing me from sending you myHorribleVirus.exe.jpg ;-)

Upvotes: 0

Related Questions