2

我的html代码

<form  method="post" enctype="multipart/form-data" ng-controller="commentCtrl" name="form">
        <a href="" type="file" class="custom-height"><img src="source/assets/images/icons/icofileattached.png" class="attachmentpng-height"  ngf-select="uploadFiles($file)" ng-model="files"/></a>
        <md-button type="submit" class="md-raised custom-submit-button" ng-click="MakeComments()"> SUBMIT </md-button>
        </form>

谢谢你的帮助

4

1 回答 1

5

这段代码对我有用....

$scope.uploadFiles = function(file) {
                console.log(file);
                $scope.fileData = file;
                var fd = new FormData();
                fd.append('file', file);
                Restangular.one('/api/files/end points').withHttpConfig({transformRequest: angular.identity})
                    .customPOST(fd, '', undefined, {'Content-Type': undefined})
            };
于 2015-11-17T07:18:20.670 回答