opticon
opticon

Reputation: 3614

Cordova File Transfer to Node Server

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

I'm getting the local URI of a 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');
                    });

The server endpoint is reached, but req.files is undefined.

What am I doing wrong?

Upvotes: 3

Views: 1174

Answers (1)

Sven
Sven

Reputation: 5265

In Express 4.x, you have to include the multer middleware to enable multipart data. After you've done that, the file will available in req.files

Upvotes: 4

Related Questions