1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Titanium.Media.openPhotoGallery({

	success:function(event)
	{
		
		var image = event.media;

		var xhr = Titanium.Network.createHTTPClient();

		xhr.onerror = function(e)
		{
			Ti.UI.createAlertDialog({title:'Error', message:e.error}).show();
			Ti.API.info('IN ERROR ' + e.error);
		};
		
		xhr.setTimeout(20000);
		
		xhr.onload = function(e)
		{
			Ti.UI.createAlertDialog({title:'Success?', message:'status code ' + this.status}).show();
			Ti.API.info('IN ONLOAD ' + this.status + ' readyState ' + this.readyState);
		};
		
		xhr.onsendstream = function(e)
		{
			
			Ti.API.info('ONSENDSTREAM - PROGRESS: ' + e.progress);
		};
		
		// open the client
		xhr.open('POST','http://localhost:3000/avatars.json?token=l6RCSwZSvft4Gw3ojZcM');
		
		// send the data
		xhr.send({image:image,image_file_name:"69a1f70.jpg"});

	}

});