科尔多瓦文件传输到节点服务器 [英] Cordova File Transfer to Node Server

查看:73
本文介绍了科尔多瓦文件传输到节点服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ng-Cordova fileTransfer插件尝试将照片从用户的相机胶卷上传到Node/Express服务器.

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.

我正在获取照片的本地URI,并尝试将其传递给插件:

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');
                    });

已到达服务器端点,但未定义req.files.

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

我在做什么错了?

推荐答案

在Express 4.x中,您必须包括 multer 中间件以启用多部分数据.完成此操作后,该文件将在req.files

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

这篇关于科尔多瓦文件传输到节点服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆