Open photogallery error.
I want to open photo gallery and upload photo to my server.
so I have made some modification to xhr_fileupload.js of kitchensink and added that file to my app. but even photo gallery is not able to open and given following error when I alert error
Error:
code=1;
source=[object Mediamodule];
success=0;
type=error;
xhr_fileupload.js code:
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();
var l1 = Titanium.UI.createLabel({
text:'UTF-8 GET',
font:{fontSize:16,fontWeight:'bold'},
top:10,
width:300,
left:10,
height:'auto'
});
win.add(l1);
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);
l1.text = this.responseText;
};
xhr.onsendstream = function(e)
{
ind.value = e.progress ;
Ti.API.info('ONSENDSTREAM - PROGRESS: ' + e.progress);
}
// open the client
xhr.open('POST','myservername/iphone1.php');
// send the data
xhr.send({media:image,action:'uploadfile'});
},
cancel:function()
{
},
error:function(error)
{
alert(error);
},
allowImageEditing:true,
});