PhoneGap iOS,如何获取应用程序"Documents"文件夹的完整路径?

mea*_*lai 13 path documents cordova

我需要将照片复制到此路径中.但如何得到它?

"iPhone模拟器/ 5.1 /应用程序/ 996C42CE-B8BF-4F1A-B16C-DBF194BD5A71/Documents /"

http://docs.phonegap.com/en/1.8.0/cordova_file_file.md.html#FileTransfer
我想将图像下载到我的app文档文件夹中.但我不知道那些文件的FullPath.

dha*_*val 19

试试这段代码:

document.addEventListener("deviceready", onDeviceReady, false);

    function onDeviceReady() {
        console.log("device is ready");
        window.requestFileSystem  = window.requestFileSystem || window.webkitRequestFileSystem;
        window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
    }

    function fail() {
        console.log("failed to get filesystem");
    }

    function gotFS(fileSystem) {
        console.log("got filesystem");

            // save the file system for later access
        console.log(fileSystem.root.fullPath);
        window.rootFS = fileSystem.root;
    }

    function downloadImage(url, fileName){
        var ft = new FileTransfer();
        ft.download(
            url,
            window.rootFS.fullPath + "/" + fileName,
            function(entry) {
                console.log("download complete: " + entry.fullPath);

            },
            function(error) {
                console.log("download error" + error.code);
            }
        );
    }
Run Code Online (Sandbox Code Playgroud)

要点显示了适用于iOS和Android的实现

  • "/"是误导性的,不是root目录,实际上是应用程序的主目录(仅在iPad上验证). (4认同)
  • 在iOS上,完整路径是'/',这真的是误导.我无法下载到这条路径.@RavindranathAkila ..你找到了解决方案..? (2认同)