I have a Drag and Drop event that is connected to my imageDrop function. I am trying to get the dataurl into an array so that I can display images via a slider view or a grid view. I am able to get the name of the file and the type I just need help figuring out how to get it to display the image.
I have tried setting up the reader.onload but when i run the page it does not output the expected values
imageDrop(e) {
e.stopPropagation();
e.preventDefault();
let dt = e.dataTransfer;
for(var i = 0, n= dt.files.length; i < n; i++){
var file = dt.files[i];
var reader = new FileReader();
reader.onload = (function(f){
return function(e){
e.target.result;
}
});(file)
this.imageFiles.push({
name: dt.files[i].name,
data: reader.readAsDataURL(file),
type: dt.files[i].type
});
}
}
What I am expecting is to get the name of the file, the type and the dataurl to display the image into the imageFiles array.