Take pic from Camera and upload on Server in Sencha Touch

takePicFromCamera(imageId,cameraSource)
{

var fileName=Math.floor((Math.random()*100000)+1);
Ext.device.Camera.capture(
{
source:cameraSource,
config:
{
quality: 75,
// scope: this,
destination: ‘data’
// encoding: ‘jpg’,
// height: “auto”,
// width: 100
// height: 197,
// width: 197
},
success: function (image)
{
//img1=image.replace(/\s/g, ”);
image=image.replace(/\s/g, ”);
var imgSrc = “data:image/png;base64,” + image;
//document.getElementById(x).src = img1;
//document.getElementById(x).src = imgSrc;
Ext.get(imageId).dom.src = imgSrc;
var jsonFile=
{
Filedata : image,
Filename : fileName+”.jpg”
};
Ext.Ajax.request({
url:’paste ur url here’ ,
method: ‘POST’,
jsonData : jsonFile,
success: function(response, opts) {
var obj = Ext.decode(response.responseText);
fileIds[(imageId.charAt((imageId.length)-1))-1]=obj;
},
failure: function(response, opts) {
alertBox(‘Fail to send image to server please try again’)
}
});

},
failure: function ()
{
//document.getElementById(x).src = resouces/;
loadMaskFun(0);
alert(‘There is something wrong with your internet. Please check your internet settings.’);
return false;
}

});

}

Advertisements
This entry was posted in Sencha Touch. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s