我使用了这段代码:
function getPicture(){
navigator.camera.getPicture(onSuccess, onFail, {
quality: 50,
destinationType: Camera.DestinationType.FILE_URI,
sourceType : Camera.PictureSourceType.SAVEDPHOTOALBUM
});
}
function onSuccess(imageURI) {
img_uri = imageURI;
alert(img_uri);
Plugin.callNativeFunction(nativePluginResultHandler, nativePluginErrorHandler, 'success', img_uri);
}
我想得到一个像这样的URI:“/ mnt / sdcard / Pictures ...”但警报给了我一个像“content:// media / external / images / media / 3915”的URI。
我该怎么办?
答案 0 :(得分:8)
您可以使用window.resolveLocalFileSystemURI来获取真实路径。您的onSuccess方法如下所示:
function onSuccess(imageURI) {
img_uri = imageURI;
alert(img_uri);
window.resolveLocalFileSystemURI(img_uri, function(fileEntry) {
alert(fileEntry.fullPath);
Plugin.callNativeFunction(nativePluginResultHandler, nativePluginErrorHandler, 'success', fileEntry.fullPath);
}, onError);
}