How to let the user to choose from Gallery or take

2019-09-02 16:15发布

问题:

This question already has an answer here:

  • Phonegap - give user option of PictureSourceType 1 answer

I want to let the user to add a pic to the Cordova application and I would like to let the user to choose the pic from his albums or take a picture instantly. How do I provide such an option using Cordova.

Does Cordova provide such a feature out of the box or we have to write one? Please advice me how to proceed with the requirement.

Cheers!

回答1:

Thanks a lot @GenieWanted & @Sumn2u for your responses, special thanks to @GenieWanted for your time and extended support.

From the answer for the following question I understand that there is no direct solution provided by Cordova to give the user an option to choose from multiple Camera.PictureSourceType. You have to pop a native/custom alert with option to choose from Gallery or Camera.

Cheers!



回答2:

Did you take a look at their Camera object? They have a clean documentation on the same. Another third party lib that you may want to look into:

https://github.com/Arcticus/Eirene/tree/master/Image%20Picker



回答3:

you have to see the proper documentation of phonegap. you are using camera you can go http://docs.phonegap.com/en/3.0.0/cordova_camera_camera.md.html#Camera for camera API

and for the storage API you have to go http://docs.phonegap.com/en/3.0.0/cordova_storage_storage.md.html#Storage for storage API

By reading this two and combining these two it will work . Further you can read the whole documentation