-
-
Save devluis/10215592 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var win = Titanium.UI.currentWindow; | |
var ind=Titanium.UI.createProgressBar({ | |
width:200, | |
height:50, | |
min:0, | |
max:1, | |
value:0, | |
style:Titanium.UI.iPhone.ProgressBarStyle.PLAIN, | |
top:10, | |
message:'Uploading Image', | |
font:{fontSize:12, fontWeight:'bold'}, | |
color:'#888' | |
}); | |
win.add(ind); | |
ind.show(); | |
Titanium.Media.openPhotoGallery({ | |
success:function(event) | |
{ | |
Ti.API.info("success! event: " + JSON.stringify(event)); | |
var image = event.media; | |
var xhr = Titanium.Network.createHTTPClient(); | |
xhr.onerror = function(e) | |
{ | |
Ti.API.info('IN ERROR ' + e.error); | |
}; | |
xhr.onload = function() | |
{ | |
Ti.API.info('IN ONLOAD ' + this.status + ' readyState ' + this.readyState); | |
}; | |
xhr.onsendstream = function(e) | |
{ | |
ind.value = e.progress ; | |
Ti.API.info('ONSENDSTREAM - PROGRESS: ' + e.progress+' '+this.status+' '+this.readyState); | |
}; | |
// open the client | |
xhr.open('POST','http://www.myserver.com/route/to/action'); | |
xhr.setRequestHeader("Connection", "close"); | |
// send the data | |
xhr.send({media:image}); | |
}, | |
cancel:function() | |
{ | |
}, | |
error:function(error) | |
{ | |
}, | |
allowImageEditing:true | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment