This is my function for uploading files:
var fd = new FormData();
fd.append("file", $scope.files[i]);
$http.post('/api/images/', fd, {
withCredentials: true,
headers: {'Content-Type': undefined },
transformRequest: angular.identity
})
.success(function(data) {
console.log(data);
})
.error(function(data) {
console.log('Error: ' + data);
});
I want to send also id with this file. I think i must add this:
fd.append("id", id);
But how i can read this on the server side? For example, when i want a name of file i write this
app.post('/api/images/', function(req, res) {
console.log(req.files.file.name);
});
But this doesn't work:
console.log(req.id);
I'm using node.js with express.