dataURL is undefined when call in addedfile
Opened this issue · 5 comments
Mostafasaffari commented
Hi guys
addedfile= file => {
console.log(file.dataURL)
}
file.dataURL undefined
How can I get it?
joaovertelo commented
Hi,
I think dataURL is present only image types.
You can get base64 with eventHandler addedFile:
addedfile(file) {
const addFile = this.props.addFile;
var reader = new FileReader();
reader.onload = function(event) {
addFile({
nome: file.name,
base64: event.target.result,
size: file.size
});
};
reader.readAsDataURL(file);
}
Way-U-Need commented
how can i access this data url outside the function
?
TedSean commented
I am getting the same undefined accessing dataURL.
NataD commented
Does anyone knows how to access dataURL?
Ibtech-wendell commented
queuecomplete: function () {
$.each(this.files, function (index, file) {
let fileReader = new FileReader();
let base64;
fileReader.onload = (fileLoadedEvent) => {
base64 = fileLoadedEvent.target.result;
file.dataURL = base64;
};
fileReader.readAsDataURL(file);
});
}