我如何从PhoneGap camera.getPicture获取一个File对象? [英] How would I get a File object from PhoneGap camera.getPicture?
本文介绍了我如何从PhoneGap camera.getPicture获取一个File对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这可能很简单,并由PhoneGap的相机插件,文件插件或文件传输插件中的一些功能组合覆盖。我理解用户可以选择一个文件:
This is probably simple and covered by some combination of functions in PhoneGap's "Camera" plugin, "File" plugin, or "File-Transfer" plugin. I understand the user can select a file with:
navigator.camera.getPicture(function (fileURI) {
// *** need help here ***
}, function ()
// handle errors
}, {
destinationType: window.Camera.DestinationType.FILE_URI,
sourceType: window.Camera.PictureSourceType.PHOTOLIBRARY,
mediaType: window.Camera.MediaType.ALLMEDIA
});
我也可以改成 destinationType:window.Camera.DestinationType.DATA_URL
如果这有区别。
I can also change to destinationType: window.Camera.DestinationType.DATA_URL
if that makes a difference.
我的目标在成功处理程序是获取一个File对象( https://developer.mozilla.org/en-US/docs/Web/API/File )。
My goal in the success handler is to get a File object (https://developer.mozilla.org/en-US/docs/Web/API/File).
推荐答案
这样应该可以做。
navigator.camera.getPicture(function (fileURI) {
window.resolveLocalFileSystemURI(fileURI,
function( fileEntry){
alert("got image file entry: " + fileEntry.fullPath);
},
function(){//error}
);
}, function (){
// handle errors
}, {
destinationType: window.Camera.DestinationType.FILE_URI,
sourceType: window.Camera.PictureSourceType.PHOTOLIBRARY,
mediaType: window.Camera.MediaType.ALLMEDIA
});
这篇关于我如何从PhoneGap camera.getPicture获取一个File对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文