[英]How to save several images at the same time in firebase using the photo camera with ionic and angular
[英]How to pick(choose) multiple images using camera API at the same time in phonegap?
使用Camera.DestinationType.FILE_URI.
时如何在phonegap camera API
同时选择或选择多个图像Camera.DestinationType.FILE_URI.
我一次只能选择一张图片。 我可以使用这个在 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 多图像选择器插件一次选择多个图像。 这是选择多个图像的好插件。
下载上面的plugin and copy paste the java classes
。 设置所需的permission
。 不要忘记复制res folder
只需复制并粘贴到您的 res 文件夹中即可。
在assets/www
创建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>
Note: This should work only cordova 3.0 and above and android 4.0 and above
打开 CameraLauncher.java 文件并替换这些行
String resizePath = getTempDirectoryPath() + "/resize.jpg";
this.callbackContext.success("file://" + resizePath + "?" + System.currentTimeMillis());
到
String resizePath = getTempDirectoryPath() + "/resize"+System.currentTimeMillis()+".jpg";
this.callbackContext.success("file://" + resizePath);
var x=0; function onPhotoDataSuccess(imageURI) { x++; // Uncomment to view the base64-encoded image data console.log(imageURI); alert(imageURI); // Get image handle // var y = 'smallImage'+x; var smallImage = document.getElementById(y); alert(smallImage); smallImage.src = "data:image/jpeg;base64," + imageURI; // Unhide image elements // smallImage.style.display = 'block'; // Show the captured photo // The in-line CSS rules are used to resize the image // //var fso=new ActiveXObject("Scripting.FileSystemObject"); //fso.CopyFile("data:image/jpeg;base64," + imageURI,"file:///storage/sdcard/DCIM/"); alert(smallImage.src) }
其中 x 是从相机和相册制作多张图像的循环
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.