我正在开发app,我必须从图库和相机中选择图片,所以我使用 cordova相机插件,我使用的是 destinationType:destinationType.FILE_URI 工作正常,现在我想将URI转换为文件对象,所以我使用文件插件V1.2.0 ,我试图使用 window.resolveLocalFileSystemURL(fileUrl,onResolveSuccess,onFail)转换为文件; 它调用on fail函数,但我有FileURl的图像路径,我从刺激器中的本地桌面选择图片,我得到的路径如 file:/// C:/用户/某些/桌面/ some / some.jpg ,即使我在移动设备上尝试过它也无法正常工作,我试图在过去4天内找到解决方案需要帮助
//select picture from gallery
function selectGallery() {
var pictureSource = navigator.camera.PictureSourceType;
var destinationType = navigator.camera.DestinationType;
navigator.camera.getPicture(onSuccessGallery,onFailGallery, {
quality: 50,
sourceType: pictureSource.PHOTOLIBRARY,
destinationType: destinationType.FILE_URI
});
}
function onSuccessGallery(fileURL) {
// i am getting fileURL: file:///C:/Users/some/Desktop/some/some.jpg
var Image
Image = document.getElementById('Image');
Image.src = fileURL;
window.resolveLocalFileSystemURL(fileURL, onResolveSuccess, onFail);
}
function onResolveSuccess (fileEntry)
{
alert("fileEntry");
}
function onFail(e)
{
alert("Error");
}