读取本地图片转Base64
document.getElementById(“upload_file”).onchange = function () { gen_base64(); }; function $_(id) { return document.getElementById(id); } function gen_base64() { var file = $_(‘upload_file’).files[0]; r = new FileReader(); //本地预览 r.onload = function(){ $_(‘base64_output’).value = r.result; } r.readAsDataURL(file); //Base64 }
读取本地图片转Base64
http://example.com/2017-11-24 读取本地图片转base64/