Created
February 5, 2020 05:40
-
-
Save SquirrelMobile/014a5de3f5199799da3d0fce2f5d90df to your computer and use it in GitHub Desktop.
Send file in form-data with Axway Titanium mobile Appcelerator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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