Hi! I use this function to upload an image to a server running node.js and express.
var uploadPhoto = function(imageURI) {
var server = "http://192.168.1.62:8080/upload";
var filePath = imageURI;
var options = {};
$cordovaFileTransfer.upload(server, filePath, options).then(function (result) {
//
}, function (err) {
alert('error');
}, function(progress) {
//
});
};
First question: What properties should be added to the options object above?
Second question: How can I get the image on the server?
router.post('/upload', function(req, res, next) {
// How can I extract the image from the request (and save it)?
// I have to mention that: req.body = {};
res.send("ok");
});
If you are using express, then use connect-multiparty module. And in your code do something like this (This is example from y app where I upload file to amazon):