How to upload image to nodeJS Server?


I’m trying to get $cordovaFileTransfer to upload some images to a nodeJS Express server, but I need some help.

On ionic I have the following code and I can get the selected images and send it to the server.

    .then(function (results) {
      for (var i = 0; i < results.length; i++) {
        console.log('Image URI: ' + results[i]);
        $cordovaFileTransfer.upload('', results[i])
          .then(function (result) {
          }, function (error) {

    }, function(error) {
      // error getting photos

On my express server I have the following code.

var express = require('express'),
    app = express(),
    path = require('path'),
    multer  = require('multer'),
    fs = require('fs');

var updLocation = path.join(__dirname, '/gallery');
var upload = multer({ dest:updLocation});'/upload', upload.array('photos'), function(req, res, next){

I keep getting the following error on the nodeJS Server when I try to upload the files. Anything else I need to do?

Server listening on port 3000
Error: Unexpected field
at makeError (/Users/enniobozzetti/WebstormProjects/demo/node_modules/multer/lib/make-error.js:12:13)
at wrappedFileFilter (/Users/enniobozzetti/WebstormProjects/demo/node_modules/multer/index.js:39:19)
at Busboy. (/Users/enniobozzetti/WebstormProjects/demo/node_modules/multer/lib/make-middleware.js:113:7)
at emitMany (events.js:127:13)
at Busboy.emit (events.js:201:7)
at Busboy.emit (/Users/enniobozzetti/WebstormProjects/demo/node_modules/busboy/lib/main.js:31:35)
at PartStream. (/Users/enniobozzetti/WebstormProjects/demo/node_modules/busboy/lib/types/multipart.js:213:13)
at emitOne (events.js:96:13)
at PartStream.emit (events.js:188:7)
at HeaderParser. (/Users/enniobozzetti/WebstormProjects/demo/node_modules/dicer/lib/Dicer.js:51:16)


I got it working. The issue was with the default file name