我有一个正在使用PhoneGap
. 我现在想将它读入指定的标签,但是当我尝试一种我知道从它读取文件时可以工作的技术时,它不起作用。这是代码;HTML
JavaScript
console.log
<p>
LocalFileSystem
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);
}
该函数readDownloadFile()
应该将 .txt 文件中的文本读readme.txt
入<p>
带有 id 的标签中mytext
。但是,当我尝试运行它时,什么也没有发生。关于我做错了什么的任何想法?