【发布时间】:2019-01-11 15:51:32
【问题描述】:
我正在从事一个项目,该项目的任务是从 sdcard 读取文本文件。文件路径在代码中给出。我尝试使用此代码但没有输出。
var path = "Download/myfile.txt";
window.resolveLocalFileSystemURL(path, success, fail);
function fail(e) {
console.error(e);
}
function success(fileEntry) {
fileEntry.file(function(file) {
var reader = new FileReader();
reader.onloadend = function(e) {
var content = this.result;
console.log(content);
};
reader.readAsText(file); // or the way you want to read it
});
}
【问题讨论】:
标签: javascript cordova android-studio phonegap file-read