Hi, Im trying to pick image from Gallery and upload to Firebase.so Can any one help me to get image from phone Gallery using Ionic 2.
You can use the Camera plugin and set the sourceType
to pull in from the users photo library, rather than using the camera itself.
Want I use ionic-native plugin or ng-cordova camera plugin?
Ionic Native. ngCordova is for Ionic 1.
Thank you.any way im big fan of your blog.
use this image picker plug-in. It uses ng-cordova . I have used this in 2 of my ionic applications.
It is very simple to get image from gallery.
First install plugin:
ionic plugin add cordova-plugin-camera
Than use this:
let options = {
destinationType : Camera.DestinationType.DATA_URL,
sourceType : Camera.PictureSourceType.PHOTOLIBRARY
};
navigator.camera.getPicture(
(data) => {
let image = "data:image/jpeg;base64," + data;
},
(error) => { },
options
);
thank you, very simple solution, no need to add image picker plugin
Well, with that solution you can only pick one image at a time. With the image picker plugin you can select multiple images at a time. So it depends on what you need really.
@sava999 your solution works for me! thxā¦
how do I get it to show in an <img afterwards? using āimageā as the source? or ādata:image/jpeg;base64,ā
this works for me as well.
And the picture layout looks better than image picker in ios.
Thanks.
Hi, Iām also trying to upload Image from Gallery and select and save it into Firebase. Iām able to go to Gallery and select a Pic. But Iām not able to save it in firebase. Could you please help me to upload image in to firebase from Photo library in Ionic2. Thanks
Hey if you still need help with posting the image to firebase check out my repo here: https://github.com/Matt4759/Ionic3-FirebaseImageSharing
Hiā¦ I used ionic native camera and i can get images using only camera. could not get images from the library.
ācamera optionā cant add to the app.module.ts . ;; I am using ionic 3
where to apply this code? @sava999