I am trying to get base64 from an image selected from an album on my phone, but I cannot get it to work:
I tried this:
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSystem) { console.log("0"); fileSystem.root.getFile(imageURI, null, function(fileEntry) { console.log("1"); fileEntry.file(function(file) { console.log("2"); var reader = new FileReader(); reader.onloadend = function(evt) { console.log("Read complete!"); image64.value = Base64.encode(evt.target.result); }; reader.readAsText(file); }, failFile); }, failFile); }, failSystem);
Although the image displays correctly .. I get an error from this function:
fileSystem.root.getFile(imageURI, null, function(fileEntry)
And error: FileError.ENCODING_ERR
I know that the code does not look very nice. But I do not know how to get Base64 encoding from imageURI.
source share