如何使用摄像头API在PhoneGap的同时挑选(选择)多张图片? [英] How to pick(choose) multiple images using camera API at the same time in phonegap?

查看:508
本文介绍了如何使用摄像头API在PhoneGap的同时挑选(选择)多张图片?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何选择或选择在同一时间多个图像在 PhoneGap的相机使用API​​的 Camera.DestinationType.FILE_URI。 code> 我能够一次挑只有一个图像。我可以选择多个文件(包括TXT,PDF ..)SD卡中使用<一个href=\"http://stackoverflow.com/questions/23868323/how-to-pickchoose-multiple-files-at-the-same-time-in-phonegap\">这。所以我想同像的图像。

How to choose or pick multiple images at the same time in phonegap camera API when using Camera.DestinationType.FILE_URI. I am able to pick only one images at a time. I am able to pick multiple files(including txt,pdf..) in sdcard using this. So i want same like for images.

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

我的科尔多瓦版本3.3,jQuery Mobile的1.3.2。

My cordova version 3.3, Jquery Mobile 1.3.2.

请提出任何插件都可以做到这一点。

Please suggest any plugins are available to do this.

推荐答案

使用此科尔多瓦多种图像选择插件要一次选择多个图像。这是很好的插件,选择多张图像。

Use this Cordova multiple image selector plugin to choose multiple image at a time. It is good plugin for choose multiple images.

下载上面的插件,然后复制粘贴Java类。设置所需的许可。不要忘了复制 res文件夹复制并在您的res文件夹粘贴。

Download the above plugin and copy paste the java classes. Set the required permission. Don't forget to copy the res folder just copy and paste in your res folder.

资产/ WWW 创建imagepicker.js复制并粘贴dowloaded imagepicker.js

Inside assets/www create imagepicker.js copy and paste the dowloaded 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>

注:这应该只科尔多瓦3.0及以上版本和Android 4.0及以上

Note: This should work only cordova 3.0 and above and android 4.0 and above

这篇关于如何使用摄像头API在PhoneGap的同时挑选(选择)多张图片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆