2012-03-27 3 views
1

Phonegap 1.5.0에서 작업 중입니다. 프로젝트에서 Android 디바이스를 사용하여 카메라에서 가져온 사진을 복사하여 다른 폴더로 이동해야합니다. 모든 이미지는 DCIM/100media/카메라에 저장됩니다. 이미지를 다른 폴더로 이동하는 방법은 무엇입니까? 나는 사전에Phonegap을 사용하여 Android 폰으로 찍은 캡처 한 이미지를 다른 폴더로 이동하는 방법

감사이 link을 언급 한

HTC 산불 S.

을 사용하고 있습니다.

답변

2

사진을 찍을 때 FILE_URI 접근법을 사용하는 경우 그 결과를 window.resolveLocalFileSystemURI에 전달하여 FileEntry 개체를 얻을 수 있습니다. 그런 다음 FileEntry에서 copyTo 메서드를 호출 할 수 있습니다.

4

다음은 저에게 도움이되는 해결책입니다. 캡처 된 이미지는 이름과

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 많은 감사 (SD 카드에서 TestFolder 폴더 로,이 경우) 사용자 지정 폴더로 이동됩니다 – surhidamatya

관련 문제