I finally came up with an iPhone app using Titanium Mobile. Now the problem that I am facing is that I can run the application, and the application also sends the image to the server. But Im could not see the file that was uploaded to the server. I pasted the iPhone application code to send the image to the server, as well as the PHP file that will receive the file from the application.
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);
};
xhr.open('POST','http://www.myserver.com/tmp/upload2.php');
xhr.setRequestHeader("Connection", "close");
xhr.send({media:image});
},
cancel:function()
{
},
error:function(error)
{
},
allowImageEditing:true
});
And here is the PHP code on the server: http://www.pastie.org/891050
I am not sure where I am going wrong. Please help me in this matter. I would like to provide if you need more information.