I managed to upload an image to my server using Cordova File Transfer plugin.
var img = <full path to image>
var url = <url to webservice>
var options = new FileUploadOptions(); //no specified options, using defaults
var ft = new FileTransfer();
ft.upload(img, encodeURI(url), win, fail, options);
var win = function (r) {
console.log('Successfully sent');
}
var fail = function (error) {
console.log("An error has occurred: Code = " + error.code);
};
However, my server had problems reading the image due to the extra header added by the plugin.
--+++++..Content-Disposition: form-data; name="file"; filename="filename.jpg"..Content-Type: image/jpeg....
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…