File upload on Android
Does file upload of an image (from gallery or taken with the camera) works for Android platform?
Which version / sample code?
3 Answers
-
Yep - You can find an example in the KitchenSink reference project.
-
This code was working as of 2 mins ago when I tested it
if (Titanium.Network.online) { var image = win.toImage(); 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.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.setTimeout(20000); xhr.open('POST','https://twitpic.com/api/uploadAndPost'); xhr.send({media:image,username:'xxx',password:'yyy',message:'check me out'}); } else { Ti.UI.createAlertDialog({title:'Dude!', message:'Umm - you need to be connected to the network'}).show(); }
ofc - you'll need to change xxx & yyy to your own password.
-
Does anyone know how to create the webservice (php) similar to
xhr.open('POST','https://twitpic.com/api/uploadAndPost');
I want to upload images to my site.