I have a page for allowing users to upload their images using drag and drop and I would like to restrict them to uploading jpg files only.
I have to admit I am a complete newbie when it comes to jquery so I really don't have a clue how to make this work.
So far I have
var files = e.dataTransfer.files;
var ext = $('#drop-files').val().split('.').pop().toLowerCase();
// Show the upload holder
$('#uploaded-holder').show();
// For each file
$.each(files, function(index, file) {
if($.inArray(ext, ['JPG','jpg','jpeg']) == -1) {
alert('invalid extension!');
return false;
}
As this is it does nothing, if I remove the 'return false' it tells me every file is invalid and uploads them anyway.
Thanks
btw, I am aware that there are unclosed brackets, I'm just hoping the someone will see something obvious I have missed out in the section of code I've supplied