Currently, I'm facing an issue with Phonegap 2.0 where I am trying to obtain a media encoded as base64 from its URI but have been unsuccessful.
function tryToSend(fileReader) {
// Unsure about what the parameter is
}
function win(file) {
alert(file.name + ' ' + file.type); // type shows as undefined at this point
var reader = new FileReader();
reader.onloadend = tryToSend;
var encoded = reader.readAsDataURL(file); // Here, 'encoded' remains undefined
}
function fail(error) {
console.log(error);
}
function onResolveSuccessCompleted(fileEntry) {
fileEntry.file(win, fail);
}
function onResolveFailed(error) {
console.log(error);
}
window.resolveLocalFileSystemURI(MY_FILE_URI, onResolveSuccessCompleted, onResolveFailed);
Despite my efforts, I have not been able to retrieve the base64 encoded data for my file which is essential for sending it in a JSON AJAX call.
I wonder if there might be something wrong with my code or if you have any suggestions on how I can achieve my goal?
Thanks.
Cyril