Skip to content

Instantly share code, notes, and snippets.

@polunzh
Created May 10, 2016 08:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save polunzh/37a3001cbceb5ca19afa35504f8cd49a to your computer and use it in GitHub Desktop.
Save polunzh/37a3001cbceb5ca19afa35504f8cd49a to your computer and use it in GitHub Desktop.
cordova image to base64
function readData(imageURI) {
function gotFileEntry(fileEntry) {
console.log("got image file entry: " + fileEntry.fullPath);
fileEntry.file(function (file) {
var reader = new FileReader();
reader.onloadend = function (evt) {
console.log(evt.target.result);
};
//reader.readAsText(file);
reader.readAsDataURL(file);
}, function (err) {
console.log(err);
});
}
function failSystem(err) {
console.log(err);
}
$ionicPlatform.ready(function () {
window.resolveLocalFileSystemURI(imageURI, gotFileEntry, failSystem);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment