Answer the question
In order to leave comments, you need to log in
How to send form data and file with AngularJS?
Hi all!
I'm making a form to send data and a file.
The data is sent without problems, but the file is not. Send data in JSON.
I am using angular-file-upload and $resource
My Code:
Controller:
var uploader = $scope.uploader = new FileUploader({
alias: 'field_title',
url: CONFIG.baseUrl + 'my_url'
});
$scope.saveFunction = function(){
$scope.uploader.uploadAll();
gaService.save($scope.gaaAccData);
}
app_services.factory('gaService', function ($resource, CONFIG) {
return $resource(CONFIG.baseUrl + "gaa/:id", {id: '@id'},
{
query: {isArray: false},
update: { method:'PUT'},
save: {method:'POST'}
});
});
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<input type="file" ng-model="gaaAccData.p12_key" ng-change="gaaAccData.p12_key.upload()" nv-file-select uploader="uploader" />
</div>
</div>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question