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

Titanium Appcelerator image upload issue When call service without image

$
0
0

I have prepared an application with image upload. It sends some text and an image.

It's working fine when I add an image and content(text). Unfortunately it's not working when I call the service without an image, see code below,

var params = {
//if file is not selected it will send as null and also try with "" empty quates
        file :$.selectedImageVw.image,    
        UserId : Ti.App.userID,
        postContent : $.postMessage.value
    };
var xhr = Titanium.Network.createHTTPClient();
    xhr.onreadystatechange = function() {
        if (this.readyState == 4) {
            progressVw.hide();
 
            // callback("Success");
            // alert(this.responseData);
            progressVw.hide();
            xhr = null;
        }
    };
 
    xhr.setRequestHeader('Content-Type', 'multipart/form-data');
    xhr.setRequestHeader('enctype', 'multipart/form-data');
    xhr.setRequestHeader('Content-length', params.length);
    xhr.open("POST", "uploadUrl");
    xhr.send(params);

FYI : I have test with Postman Rest Client(Google API). But with the same parameters and working good. When done with mobile only not working. So from the backend not an issue.

Hope Some one will help to resolve this issue.

Thanks in Advance!


Viewing all articles
Browse latest Browse all 8068

Trending Articles



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