Angularjs 客户端和服务器之间的Http请求不同

Angularjs 客户端和服务器之间的Http请求不同,angularjs,node.js,http,Angularjs,Node.js,Http,在客户端,我使用$http发送一个请求: Upload.upload({ url: 'http://localhost:3000/upload', fields: { 'username': $scope.username }, file: file }) 在服务器端,这是路由: app.route('/upload') .get(function (req) { for (var key

在客户端,我使用$http发送一个请求:

Upload.upload({
       url: 'http://localhost:3000/upload',
       fields: {
            'username': $scope.username
       },
       file: file
})
在服务器端,这是路由:

app.route('/upload')
    .get(function (req) {
        for (var key in req)
            console.log(key);
})

但我在req中看不到任何密钥名文件?这两者之间差异的原因是什么?

您需要使用post添加头以上载文件,需要发出多部分/表单数据请求

   var fd = new FormData();
     fd.append("file", file);

    $http.post(uploadUrl, fd, {
        withCredentials: true,
        headers: {'Content-Type': undefined },
        transformRequest: angular.identity
    })
请参见

应用程序当前使用的中间件是什么?有人体分析器吗?