Please below is my code in the scripting section of my vue component.
I correctly understood all the input fields, but when loading images and videos, empty values ββare displayed.
I tried to solve this problem, but to no avail.
playVideo(url) {
let video = $('#video-preview').get(0);
video.preload = 'metadata';
if (url) {
video.muted = false;
video.playsInline = true;
video.play();
}
},
readDataUrl(input, callback) {
if (input.files && input.files[0]) {
let fileReader = new FileReader();
fileReader.onload = function () {
callback(fileReader.result);
};
fileReader.readAsDataURL(input.files[0]);
}
else {
callback(null);
}
},
readObjectUrl(input, callback) {
if (input.files && input.files[0]) {
let fileReader = new FileReader();
fileReader.onload = function () {
let blob = new Blob([fileReader.result], {type: input.files[0].type});
let url = URL.createObjectURL(blob);
callback(url, blob);
};
fileReader.readAsArrayBuffer(input.files[0]);
}
else {
callback(null);
}
},
}
}
What I want to achieve is to upload an image and a video file, preview them before saving them as a blob object.

The image above shows my @samayo answer
The image and video block display blank values.
source
share