Click here to Skip to main content
15,886,724 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to read an image from Phonememory folder but unable to read.
i have no idea whats wrong.
can anybody help me out

What I have tried:

<script>

document.addEventListener("deviceready", onDeviceReady, false);

function onDeviceReady() {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, onFail);
}

function onFail(message) {
alert('Failed because: ' + message);
}

function gotFS(fileSystem) {
fileSystem.root.getFile("/MyAppFolder/A.jpg", { create: true }, gotFileEntry, fail);
}

function gotFileEntry(fileEntry) {
fileEntry.file(gotFile, fail);
}

function gotFile(file) {
readDataUrl(file);
}

function readDataUrl(file) {
var reader = new FileReader();
reader.onloadend = function (evt) {
console.log("Read as data URL");
console.log(evt.target.result);
document.getElementById("profileimg").src = evt.target.result;
};
reader.readAsDataURL(file);
}

function fail(evt) {
console.log(evt.target.error.code);
}

</script>
Posted
Comments
Richard MacCutchan 29-Feb-16 3:47am    
fileSystem.root.getFile("/MyAppFolder/A.jpg", { create: true }, gotFileEntry, fail);
I don't know cordova, but wonder if that path may not be correct.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900