File to Base64
/**
* File to Base64
* @param { File } 文件
*/
const fileToBase64 = (file = new File()) => new Promise((resolve, reject) => {
let reader = new FileReader();
reader.onload = () => resolve(`data:${file.type};base64,${reader.result.split(",")[1]}`);
reader.onerror = () => reject(reader.error);
reader.readAsDataURL(file);
});
本文链接:
/archives/file-to-base64
版权声明:
本站所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自
CaptainTwo!
喜欢就支持一下吧