I have an app I'm developing using PhoneGap
, HTML
and JavaScript
and so far I have the app downloading a file and reading it to the console.log
. I now want to read it into specified <p>
tags but when I try a technique I know to work when reading a file from the LocalFileSystem
it doesn't work. Here's the code;
function downloadfile() {
var fileTransfer = new FileTransfer();
var uri = encodeURI("http://dl.dropbox.com/u/97184921/readme.txt");
fileTransfer.download(
uri,
'/Users/administrator/Library/Application Support/iPhone Simulator/6.1/Applications/AF96D141-0CE5-4D60-9FA8-8A8F9A999C81/Documents/readme.txt',
function(entry) {
console.log("download complete: " + entry.fullPath);
},
function(error) {
console.log("download error source " + error.source);
console.log("download error target " + error.target);
console.log("upload error code" + error.code);
}
);
}
function readDownloadedFile() {
myFileSystem.root.getFile("readme.txt", {create: false, exclusive: false}, gotDownloadFileEntry, fail);
var myDownload = document.getElementById("mytext");
myDownload.innerText = text;
}
function gotDownloadFileEntry(fileEntry) {
console.log(fileEntry);
fileEntry.file(gotFile, fail);
}
The function readDownloadFile()
is supposed to read the text in the .txt file readme.txt
into the <p>
tags with the id mytext
. However, when I try and run it nothing happens. Any ideas on what I'm doing wrong?