无法将图像保存到自定义文件夹

时间:2015-03-27 22:57:14

标签: javascript cordova

我正在尝试从SD卡复制图像并将其移动到以SD编程方式在SD中创建的不同文件夹,我的代码是HTML,JS代码在这里用作错误回调而不是成功。

<button id="choose_img">Choose Picture</button>

jQuery("#choose_img").on("click",function(){
    navigator.camera.getPicture(onSuccess, onFail, { quality: 50,
    destinationType: Camera.DestinationType.FILE_URI,sourceType: Camera.PictureSourceType.PHOTOLIBRARY
 }); 

})

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

function onFail(message) {
    alert('Failed because: ' + message);
}

function movePic(imageURI){ 
    window.resolveLocalFileSystemURL(imageURI, resolveOnSuccess, resOnError); 
} 

function resolveOnSuccess(entry){ 
console.log(entry);

     var newFileName =  "abc.jpg";
    var myFolderApp = "EasyPacking";

    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 - inserting the complete path
function successMove(entry) {
    //I do my insert with "entry.fullPath" as for the path
}

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

}

0 个答案:

没有答案