Uploading Cordova File to Node Server

I am using the fileTransfer ng-Cordova plugin to try and upload a photo from a user's camera roll to a Node / Express server.

I am getting the local URI of the photo and trying to pass it to the plugin as such:

$cordovaFileTransfer.upload('http://135.23.98.169:8069/upload_avatar', fileURI)
                    .then(function (result) {
                        console.log('success');
                    }, function (error) {
                        console.log('what');
                    });

      

Server endpoint reached, but req.files

undefined.

What am I doing wrong?

+3


source to share


1 answer


In Express 4.x, you must enable the multer middleware to enable multipart data. After you do this, the file will be available inreq.files



+4


source







All Articles