Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pietromalerba/5510000 to your computer and use it in GitHub Desktop.
Save pietromalerba/5510000 to your computer and use it in GitHub Desktop.
Titanium showcamera register and uploads
Titanium.Media.showCamera({
success:function(event)
{
var cameraView = Titanium.UI.createImageView({width:'auto', height:'auto', top: 0, left: 0, image: event.media});
var imageNew0 = cameraView.toImage(function(e){
var filename1 = Titanium.Filesystem.applicationDataDirectory + "/NAMEOFTHEPICTURE1.png";
f1 = Titanium.Filesystem.getFile(filename1);
f1.write(e.blob);
Titanium.Media.saveToPhotoGallery(f1);
var xhr = Titanium.Network.createHTTPClient();
xhr.open('POST','http://192.168.1.6/upload.php');
xhr.onerror = function(e){alert(e.error);};
xhr.setTimeout(200000);
xhr.onload = function(e){Ti.UI.createAlertDialog({title:'Success', message: this.responseText}).show();};
xhr.onsendstream = function(e){Ti.API.info(e);};
xhr.setRequestHeader("contentType", "multipart/form-data");
xhr.send({uploadedfile:filename1});
});
//var myImage = event.media;
Titanium.Media.hideCamera();
var url = "message.wav";
var sound = Titanium.Media.createSound({url:url,preload:true});
sound.play();
},
cancel:function(){},
error:function(error){},
overlay:overlay,
showControls:false,
mediaTypes:Titanium.Media.MEDIA_TYPE_PHOTO,
autohide:false,
transform:cameraTransform
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment