【问题标题】:how to upload a file in Restangularjs using multipart/formdata如何使用多部分/表单数据在 Rest Angularjs 中上传文件
【发布时间】:2015-11-16 07:43:04
【问题描述】:

我的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>

感谢您的帮助

【问题讨论】:

标签: angularjs angular-file-upload


【解决方案1】:

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

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

【讨论】:

  • 你能解释一下你的答案吗
猜你喜欢
  • 2014-08-18
  • 2023-03-25
  • 2015-03-13
  • 2012-12-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-02-15
相关资源
最近更新 更多