Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Image base64 not sending to database in android

$
0
0

Hi I Have problem in when am converting the image into base64 format and sending to database in android but in ios simulator it's working fine .Can any one guide me where I did wrong.Here I wrote the code like this

Titanium.Media.openPhotoGallery({
        success : function(e) {     
 
 
            var image = e.media;
                Titanium.API.info('image url: ' + e.media);
             imgStr=Ti.Utils.base64encode(image).toString();
             Titanium.API.info('image url: ' + imgStr); 
 
 
        },
        cancel : function() {
            Ti.API.info('user cancelled galary.');
 
        },
        error : function(error) {
            var alert = Titanium.UI.createAlertDialog({
                title : 'Sorry!',
                message : 'Error: ' + error.code
            });
            alert.show();
        },
        mediaTypes : Ti.Media.MEDIA_TYPE_PHOTO
    });
});
and for sending I wrote the code like this
var imgxhr = Titanium.Network.createHTTPClient();
         imgxhr.onload = function(e) {      
            // Titanium.API.info('image url: ' + this.responseText);
             var imgparse = JSON.parse(this.responseText);
 
             imageUrlvalue = imgparse.url;
              alert(' submitImage image parse: ' + imageUrlvalue);
 
          };    
 
          imgxhr.onerror = function(e) {
 
                alert("test :"+e.error);
 
          };
          var imgData = {
              profilepic : imgStr,
          };
            Titanium.API.info(' post image url: ' + JSON.stringify(imgData));
          imgxhr.open('POST',Alloy.Globals.apiurl+'UploadProfile');
            //xhr.setRequestHeader('Content-Type', "application/json; charset=utf-8");
          imgxhr.setRequestHeader('Content-Type', "apapplication/x-www-form-urlencoded; charset=utf-8");
          imgxhr.send(imgData);

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>