这可能很简单,PhoneGap 的“相机”插件、"file"插件或“文件传输”插件中的一些功能组合涵盖了这一点。我知道用户可以选择一个文件:
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
如果有区别的话。
我在成功处理程序中的目标是获取一个文件对象 ( https://developer.mozilla.org/en-US/docs/Web/API/File)。
最佳答案
像这样的东西应该可以做到。
navigator.camera.getPicture(function (fileURI) {
window.resolveLocalFileSystemURL(fileURI,
function(fileEntry){
alert("got image file entry: " + fileEntry.fullPath);
// fileEntry.file() should return a raw HTML File Object
},
function(){//error}
);
}, function (){
// handle errors
}, {
destinationType: window.Camera.DestinationType.FILE_URI,
sourceType: window.Camera.PictureSourceType.PHOTOLIBRARY,
mediaType: window.Camera.MediaType.ALLMEDIA
});
关于javascript - 我如何从 PhoneGap camera.getPicture 获取文件对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22153644/