Cordova File Transfer to Node Server

萝らか妹 提交于 2020-01-13 05:00:26

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!