As Convert local image to base64 string in Javascript . I know how to use it, but it work if image file include in project, not work with another folder. I'm test in android device and my image path like:
/storage/extSdCard/1.jpg
How can i convert image from local mobile device to base64?
function readImage(url, callback) {
var request = new
XMLHttpRequest(); request.onload = function() {
var file = new FileReader();
file.onloadend = function() {
callback(file.result);
}
file.readAsDataURL(request.response); };
request.open('GET', url);
request.responseType = 'blob';
request.send();
}
and call function
readImage('[path image] ', function(base64) { console.info(base64);
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.