Phonegap图像文件不会永久保存iOS

时间:2014-10-28 07:53:32

标签: ios cordova

您好我正在尝试捕获照片并将其永久保存到文件系统中。拍摄照片到目前为止,但它似乎不会永久保存到文件系统。重新启动应用程序后,图片消失了。 图片的路径保存到我的WebSQL数据库(没有问题)

以下是我的代码部分:

function capturePhoto() {
    navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50,
        destinationType: destinationType.FILE_URI, saveToPhotoAlbum: true });
}

function onFail(message) {
    console.log('Failed because: ' + message);
}

function onPhotoDataSuccess(imageURI) {
    movePic(imageURI);
}

function movePic(file){
    window.resolveLocalFileSystemURI(file, resolveOnSuccess, resOnError);
}

//Callback function when the file system uri has been resolved
function resolveOnSuccess(entry){
    var d = new Date();
    var n = d.getTime();
    //new file name
    var newFileName = n + ".jpg";
    var myFolderApp = "LeadAppPhotos";

    window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSys) {
            //The folder is created if doesn't exist
            fileSys.root.getDirectory( myFolderApp,
                {create:true, exclusive: false},
                function(directory) {
                    entry.moveTo(directory, newFileName,  successMove, resOnError);
                },
                resOnError);
        },
        resOnError);
}

//Callback function when the file has been moved successfully
function successMove(entry) {

    //put the path url in a div so i can save it later to my websql database
    $('#hidden_photo').val(entry.fullPath);
}

function resOnError(error) {
    alert(error.code);
}

我的错是什么?

0 个答案:

没有答案