Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

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,

});

— asked April 6th 2010 by vikas khairnar
  • openphotogallery
0 Comments

0 Answers

The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.