javascript– 如何在phonegap中同时使用相机API选择(选择)多个图像?

javascript– 如何在phonegap中同时使用相机API选择(选择)多个图像?,第1张

概述使用Camera.DestinationType.FILE_URI时,如何在phonegap相机API中同时选择或选择多个图像.我一次只能选择一张图像.我可以使用this在sdcard中选择多个文件(包括txt,pdf..).所以我想要像图像一样.navigator.camera.getPicture(function(imageData){window.resolveLocalFileSys

使用Camera.DestinationType.file_URI时,如何在phonegap相机API中同时选择或选择多个图像.我一次只能选择一张图像.我可以使用 this在sdcard中选择多个文件(包括txt,pdf ..).所以我想要像图像一样.

navigator.camera.getPicture(function(imageData) {window.resolveLocalfileSystemURI(imageData, function(fileEntry) {            fileEntry.file(function(fileObj) {                    }, onFail, {    quality : 50,    destinationType : Camera.DestinationType.file_URI});

我的cordova版本3.3,Jquery Mobile 1.3.2.

请建议任何插件都可以执行此 *** 作.

解决方法:

使用此Cordova multiple image selector plugin一次选择多个图像.这是选择多个图像的好插件.

下载上面的插件并复制粘贴java类.设置所需的权限.不要忘记复制res文件夹只需复制并粘贴到res文件夹中.

insIDe assets / www create imagepicker.Js复制并粘贴已下载的imagepicker.Js

在你的index.HTML中设置如下:

<script type="text/JavaScript" src="cordova.Js"></script><script type="text/JavaScript" src="imagepicker.Js"></script><script type="text/JavaScript">    document.addEventListener("deviceready",onDeviceReady,false);    function onDeviceReady(){        window.imagePicker.getPictures(                function(results) {                    for (var i = 0; i < results.length; i++) {                        alert('Image URI: ' + results[i]);// read file type and size and file name like below(in comment)/* window.resolveLocalfileSystemURI(results[i], function(fileEntry){        fileEntry.file(function(fileObj) {             alert(fileEntry.name);            alert(fileObj.size);            alert(fileObj.type);        });     }, function (error) {            alert('Error: ' + error);        });*/                    }                }, function (error) {                    alert('Error: ' + error);                }            );    }    </script>

注意:这应该只适用于cordova 3.0及以上版本以及androID 4.0及以上版本

总结

以上是内存溢出为你收集整理的javascript – 如何在phonegap中同时使用相机API选择(选择)多个图像?全部内容,希望文章能够帮你解决javascript – 如何在phonegap中同时使用相机API选择(选择)多个图像?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1117970.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-29
下一篇2022-05-29

发表评论

登录后才能评论

评论列表(0条)

    保存