小编Cac*_*cos的帖子

MEAN堆栈文件上传

我最近开始使用MEAN Stack编程,我目前正在实现某种社交网络.一直在使用MEAN.io框架来做到这一点.我现在的主要问题是让文件上传工作,因为我想要做的是从表单接收文件到AngularJS控制器并将其与更多信息一起传递给ExpressJS,这样我最终可以将所有内容发送到MongoDB.(我正在构建一个注册新用户表单).

我不想将文件本身存储在数据库中,但我想存储一个链接.

我在google上用不同的搜索查询搜索了几十页,但我找不到任何我能理解或工作的内容.一直在寻找没有结果的时间.这就是我来到这里的原因.

谁能帮我这个?

谢谢 :)

编辑:也许一些代码将有助于理解.

我作为基础使用的默认MEAN.io Users Angular控制器具有以下功能:

$scope.register = function(){
        $scope.usernameError = null;
        $scope.registerError = null;
        $http.post('/register', {
            email: $scope.user.email,
            password: $scope.user.password,
            confirmPassword: $scope.user.confirmPassword,
            username: $scope.user.username,
            name: $scope.user.fullname
        })//... has a bit more code but I cut it because the post is the main thing here.
    };
Run Code Online (Sandbox Code Playgroud)

我想要做的是:从表单接收文件到这个控制器并将其与电子邮件,密码,名称等一起传递,并且能够使用位于服务器端的expressjs上的json.'/ register'是一个nodejs路由,因此服务器控制器创建用户(使用用户模式)并将其发送到MongoDB.

mongodb node.js express angularjs mean-stack

19
推荐指数
1
解决办法
2万
查看次数

标签 统计

angularjs ×1

express ×1

mean-stack ×1

mongodb ×1

node.js ×1