Iphone phonegap iOS应用程序文档文件夹中文件的文件url?
如果我需要在html文件中引用phonegap iOS应用程序的documents文件夹下的文件url,那么该文件的url是什么样子的?phonegap项目中的www文件夹是根文件夹。例如,该文件夹中的image.png添加了Iphone phonegap iOS应用程序文档文件夹中文件的文件url?,iphone,cordova,Iphone,Cordova,如果我需要在html文件中引用phonegap iOS应用程序的documents文件夹下的文件url,那么该文件的url是什么样子的?phonegap项目中的www文件夹是根文件夹。例如,该文件夹中的image.png添加了 <img src="image.png" /> 我参考了保存在文档文件夹中的图像,如下所示:/var/mobile/Applications/21F126D3-D345-490D-91C6-7619CC682944/documents/'name'。jpg
<img src="image.png" />
我参考了保存在文档文件夹中的图像,如下所示:/var/mobile/Applications/21F126D3-D345-490D-91C6-7619CC682944/documents/'name'。jpg 带有字母和数字的部分对于每个应用程序都是独立的,因此您的应用程序将有所不同。您可以通过以下方式获得:
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSys) {
var pathToRoot = fileSys.root.fullPath;
}, function() {
console.log('****iPhone:Error when requesting persisten filesystem to find root path.');
});
这一点在本节中进行了解释
getAbsolutePath("mead.jpg",
function(entry){
//alert(entry.fullPath);
$("#img_test").attr("src",entry.fullPath);
console.log("jq$:=" + entry.fullPath);
//$("#img_test").attr("src","img/test.jpg");
});
// file system
function getAbsolutePath(file_name,call_back){
var full_path = "";
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0,
function (file_system){
file_system.root.getFile(
file_name,
{create: false},
call_back
,
function(){
console.log("failed to fetch file, please check the name");
}
);
},
function(){
console.log("failed file sytem");
}
);
}