I'm creating a jQuery drag and drop upload. I've created everything perfectly so far and stored the files in an array.
Here's the final step:
$('.single-product form.cart').submit(function(e){
e.preventDefault();
console.table(files);
$('.wcfu-validation').hide();
var filetypes = ['image/png'];
$.each(files, function(key, value, e){
if($.inArray(value.type, filetypes)){
$('.wcfu-validation').show();
} else {
$('input[type="file"]').prop('files', files);
}
});
});
Here I'm checking to see if the uploaded file(s) is in the accepted file types array, if it is, then we can loop through each file in the files
array and append to the HTML file
input.
However, I'm getting this error:
Here's what my array looks like as an example if I upload 2 PNG files:
What am I doing wrong?