Skip to content

Instantly share code, notes, and snippets.

@SquirrelMobile
Created February 5, 2020 05:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SquirrelMobile/014a5de3f5199799da3d0fce2f5d90df to your computer and use it in GitHub Desktop.
Save SquirrelMobile/014a5de3f5199799da3d0fce2f5d90df to your computer and use it in GitHub Desktop.
Send file in form-data with Axway Titanium mobile Appcelerator
var pathToFile = "YOUR PATH TO FILE HERE";
var baseurlAPI = "YOUR API BASEURL HERE";
var file = Ti.Filesystem.getFile(pathToFile);
if(file.exists()){
var xhr = Ti.Network.createHTTPClient({
onload: function(e) {
Ti.API.log('success '+this.responseText);
},
onerror: function(e) {
Ti.API.error(this.responseText);
},
timeout : -1
});
xhr.open('POST', baseurlAPI);
xhr.send({
file: file
});
}else{
console.log('didnt exist ' + file.nativePath);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment