Reputation: 676
I am very new to phonegap. For learning purpose I am trying to make an app which let the user to select an image from phone or SD card storage . After selecting, the app will display that image on screen. I have searched over the net for this, but I did not find. Please give me any suggestion how to do that.
Upvotes: 0
Views: 799
Reputation: 406
By using this link http://docs.phonegap.com/en/edge/cordova_camera_camera.md.html#Camera you can easily create an app like that.
function getPhoto(source)
{
navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 50,
destinationType: navigator.camera.DestinationType.FILE_URI,
sourceType: source });
}
function onPhotoURISuccess(imageURI)
{
var largeImage = document.getElementById('largeImage');
largeImage.style.display = 'block';
largeImage.src = imageURI;
}
function onFail(message)
{
alert('Failed because: ' + message);
}
**html page**
<button onclick="getPhoto(navigator.camera.PictureSourceType.SAVEDPHOTOALBUM);">From Photo Album</button><br/>
<img style="display:none;width:60px;height:60px;" id="largeImage" src="" />
Upvotes: 2