i have an app in JavaScript where a user can upload an image and it will save it in a database after converting it to base64 string, now i want the images to be compressed so it wont take as much space in the DB. here is my current code with out compression.
this.imgUrl = "";
const imgs = event.target.files;
let imgName = imgs[0].name;
if (imgName.lastIndexOf(".") <= 0) {
//invalid file
} else {
const fileReader = new FileReader();
fileReader.addEventListener("load", () => {
this.imgUrl = fileReader.result;
});
fileReader.readAsDataURL(imgs[0]);
}
I would like to hear your thoughts. (Using Vue btw) Thank you!