我正在尝试使用phoneGap以及jquery(移动)和PHP在应用程序中显示来自远程服务器的图像。
我从文档中了解到该函数可以完成这项工作:
FileTransfer
这里:http://docs.phonegap.com/en/1.6.0/cordova_file_file.md.html
// !! Assumes variable url contains a valid URI to a file on a server and filePath is a valid path on the device
var fileTransfer = new FileTransfer();
fileTransfer.download(
url,
filePath,
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);
}
);
我的问题是我不知道到达应用程序根目录的文件路径应该是什么? 主要问题(这就是我创建这篇文章的原因)是我从文档中读到
It is also possible to download a file from remote and save it on the device (only iOS and Android).
这对我来说是个问题..
那么我应该做什么,我可以将服务器上的图像网址提供给我的phonegap应用程序中图像的src吗?这行得通吗?
谢谢
最佳答案
我通常使用 html 标签在 PhoneGap 应用程序中显示来自远程服务器的图像。
关于javascript - 在 PhoneGap 应用程序中从服务器远程显示图像的最佳方式是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17424608/