📜  javascript base64 编码文件输入 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:57.812000             🧑  作者: Mango

代码示例2
var fileInput = document.getElementById('#myInputID');

var reader = new FileReader();
reader.readAsDataURL(fileInput.files[0]);

reader.onload = function () {
    console.log(reader.result);//base64encoded string
};
reader.onerror = function (error) {
    console.log('Error: ', error);
};