如何使用multipart / formdata在Restangularjs中上传文件 [英] how to upload a file in Restangularjs using multipart/formdata
本文介绍了如何使用multipart / formdata在Restangularjs中上传文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的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>
感谢您的帮助
推荐答案
这段代码对我有用....
This piece of code worked for me....
$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})
};
这篇关于如何使用multipart / formdata在Restangularjs中上传文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文