Skip to content

Instantly share code, notes, and snippets.

@deyvin
Created March 30, 2012 00:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save deyvin/2245359 to your computer and use it in GitHub Desktop.
Save deyvin/2245359 to your computer and use it in GitHub Desktop.
image upload (device to server) with Titanium Mobile
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
});
@xtarx
Copy link

xtarx commented Oct 23, 2013

Is there anyway to get the Image CreationDate too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment