问题
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?
回答1:
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
来源:https://stackoverflow.com/questions/29949902/cordova-file-transfer-to-node-server