Skip to content

Instantly share code, notes, and snippets.

@pedrobrasileiro
Created May 13, 2014 23:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pedrobrasileiro/a545a687fed173557a37 to your computer and use it in GitHub Desktop.
Save pedrobrasileiro/a545a687fed173557a37 to your computer and use it in GitHub Desktop.
Upload Photo
var http = Ti.Network.createHTTPClient({
onerror : function(e) {
console.error('Error Send Photo : '+ e);
args.error(e);
},
onload : function () {
console.debug('Success Send Photo : '+ JSON.stringify(data));
args.success({responseText : this.responseText});
},
onsendstream : function(e) {
if (abortSendPhoto == true) {
console.debug("Aborting Photo Upload...");
http.abort();
abortSendPhoto = false;
}
args.progress(e);
}
});
var data = {
uploadedFile : args.media
};
console.debug('Send Photo : '+ args.url);
http.open('POST', args.url);
http.setRequestHeader('enctype','multipart/form-data');
http.setRequestHeader('Content-Length', args.media.length);
http.setRequestHeader('Connection', 'close');
http.send(data);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment