我正在使用Phonegap 1.5.0,我們的項目需要使用Android設備複製從相機拍攝的照片並將其移至另一個文件夾。所有圖像都存儲在DCIM/100media/camera中。 如何將這些圖像移動到另一個文件夾?我使用的HTC野火S.如何將使用Android手機拍攝的拍攝圖像移動到使用Phonegap的另一個文件夾
我已經提到這個link,提前
感謝。
我正在使用Phonegap 1.5.0,我們的項目需要使用Android設備複製從相機拍攝的照片並將其移至另一個文件夾。所有圖像都存儲在DCIM/100media/camera中。 如何將這些圖像移動到另一個文件夾?我使用的HTC野火S.如何將使用Android手機拍攝的拍攝圖像移動到使用Phonegap的另一個文件夾
我已經提到這個link,提前
感謝。
然後看看這個鏈接也;) http://docs.phonegap.com/en/1.4.1/phonegap_file_file.md.html#File
後ü拍攝照片,日子會把你返回的PIC的路徑,ü可以用它來保存到使用文件API另一個位置。只是讀寫
如果您在拍攝照片時使用FILE_URI方法,則可以將該結果傳遞給window.resolveLocalFileSystemURI以獲取FileEntry對象。然後,您可以在FileEntry上調用copyTo方法。
這是爲我工作的解決方案。拍攝的圖像將被重新命名,並(在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);
};
}
非常感謝您的代碼幫me.Many非常感謝移動到自定義文件夾 – surhidamatya 2013-09-30 05:26:19