2012-03-27 54 views

回答

4

這是爲我工作的解決方案。拍攝的圖像將被重新命名,並(在SD卡在這種情況下,該文件夾TestFolder

function capture() { 

    // Retrieve image file location from specified source 
    navigator.camera.getPicture(getImageURI, function(message) { 
     alert('Image Capture Failed'); 
    }, { 
     quality : 40, 
     destinationType : Camera.DestinationType.FILE_URI 
    }); 

} 

function getImageURI(imageURI) { 

    var gotFileEntry = function(fileEntry) { 
     alert("got image file entry: " + fileEntry.fullPath); 
     var gotFileSystem = function(fileSystem) { 

      fileSystem.root.getDirectory("TestFolder", { 
       create : true 
      }, function(dataDir) { 

       // copy the file 
       fileEntry.moveTo(dataDir, "1.jpg", null, fsFail); 

      }, dirFail); 

     }; 
     // get file system to copy or move image file to 
     window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFileSystem, 
       fsFail); 
    }; 
    // resolve file system for image 
    window.resolveLocalFileSystemURI(imageURI, gotFileEntry, fsFail); 

    // file system fail 
    var fsFail = function(error) { 
     alert("failed with error code: " + error.code); 

    }; 

    var dirFail = function(error) { 
     alert("Directory error code: " + error.code); 

    }; 
} 
+1

非常感謝您的代碼幫me.Many非常感謝移動到自定義文件夾 – surhidamatya 2013-09-30 05:26:19

相關問題