Online tool:
Code:
js
function getBase64(file) {
return new Promise((res, rej) => {
var reader = new FileReader();
reader.onloadend = function () {
res(reader.result);
};reader.onerror = function (e) {
rej(e);
};reader.readAsDataURL(file);
});
}
See: