Node.js 在服务器端访问上传图像

Node.js 在服务器端访问上传图像,node.js,angularjs,Node.js,Angularjs,我应该上传图像并将其存储在GridFS中。我这里的问题是,我没有得到服务器端用户选择的图像 <input type="file" name="letterhead" /> 它显示我未定义。我看到您将其标记为AngularJS,因此我假设您使用AngularJS控制器中的文件输入。据我所知,ngModel对文件输入不起作用。我个人是这样做的 <input type="file" id="uploadImage" name="uploadImage" onchange="angu

我应该上传图像并将其存储在GridFS中。我这里的问题是,我没有得到服务器端用户选择的图像

<input type="file" name="letterhead" />

它显示我未定义。

我看到您将其标记为AngularJS,因此我假设您使用AngularJS控制器中的文件输入。据我所知,ngModel对文件输入不起作用。我个人是这样做的

<input type="file" id="uploadImage" name="uploadImage" onchange="angular.element(this).scope().setFiles(this)">

你是在做form post还是ajax post
<input type="file" id="uploadImage" name="uploadImage" onchange="angular.element(this).scope().setFiles(this)">
$scope.setFiles = function (element) {
        $scope.$apply(function () {
            $scope.file = element.files[0];
            //from now on you can do whatever you want with your image $scope.file
        });
    };