Here is the code snippet from the script section of my Vue component:
While I am able to get all the input field values correctly, the image and video uploads are displaying empty values.
Despite my attempts to address this issue, I have been unsuccessful so far.
playVideo(url) {
let video = $('#video-preview').get(0);
video.preload = 'metadata';
// Load video in Safari / IE11
if (url) {
video.muted = false;
video.playsInline = true;
video.play();
}
},
// Read a file input as a data URL.
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);
}
},
// Read a file input as an object url.
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);
}
},
}
}
I am aiming to upload an image and video file, preview them, and save them as blobs.
https://i.sstatic.net/urLLw.jpg
The screenshot above highlights my response to @samayo
However, I am encountering issues with the image and video blobs appearing as empty values.