I have a drag and drop function to handle both web and local file uploading. The local file drag n' drop works fine in chrome and firefox but IE give me the following error 'Unable to get property of '0' of undefined or null reference'. Below is my JS for the drop action. IE is pointing at the beginning of my if statement as the cause of the issue. Am I missing an API of some kind or is there something I have to declare for IE to work?
$("#blightImgBack").on('drop', function(e) {
debugger;
console.log('on drop');
if (e.originalEvent.dataTransfer.items[0].kind === 'file') {
console.log('local file');
imageLoaderBack = document.getElementById('blightImgBack');
imageLoaderBack.addEventListener('change', handleBackImage);
function handleBackImage(e) {
console.log('function fired');
e.preventDefault();
var reader = new FileReader();
reader.onload = function (event) {
console.log('updating src');
$('#backImgUploader img').fadeOut(200, function() {
$('#backImgUploader img').attr('src',event.target.result);
$('#backImgUploader img').fadeIn(300);
});
};
reader.readAsDataURL(e.target.files[0]);
}
} else if (e.originalEvent.dataTransfer.items[0].kind === 'string') {
e.preventDefault();
e.originalEvent.dataTransfer.items[0].getAsString(function (url) {
$('#backImgUploader img').fadeOut(200, function() {
$('#backImgUploader img').attr('src', url);
$('#backImgUploader img').fadeIn(300);
});
});
}
});