c# - Angular Js Mutiple Upload Controls with a single upload button -
i know how can upload files using multiple upload controls single upload button. have upload control uploads images folder , upload control b uploads images folder b. when clicks on upload button $scope.data lists 4 files. these 4 files selected 2 upload controls. how can know file selected upload control
contoller.js
$scope.uploadfiles = function () { $scope.uploading = true; testservice.uploadpackageimages($scope) // then() called when uploadfiles gets .then(function (data) { // promise fulfilled $scope.uploading = false; if (data === '') { alert("done!!!") $scope.formdata = new formdata(); $scope.data = []; $scope.countfiles = ''; $scope.$apply; } else { //server error alert(" happended there!!! " + data); } }, function (error) { $scope.uploading = false; //server error alert(" happended there!!! " + error); } ); };
service.js
function uploadpackageimages($scope) { debugger; var request = { method: 'post', url: 'api/upload/', data: $scope.formdata, headers: { 'content-type': undefined } }; // send files. return $http(request) .then( function (response) { if (typeof response.data === 'string') { return response.data; } else { return $q.reject(response.data); } }, function (response) { return $q.reject(response.data); } ); }
html
<div class="fileinput fileinput-new" data-provides="fileinput"> <div class="col-lg-6 col-sm-6 col-12"> <div class="input-group"> <span class="input-group-btn"> <span class="btn btn-primary btn-file"> browse...<input type="file" multiple my-directory="getfiles(file)" ng-disabled="uploading" /> </span> </span> <input type="text" ng-model="countfiles" class="form-control" readonly> </div> <input type="button" class="btn btn-default btn-primary" ng-click="uploadfiles()" value="upload" ng-disabled="uploading || countfiles===''" /> <div ng-repeat="file in data "> {{file.filename + ' ' + file.filelength + ' bytes' }} </div> </div> </div>
Comments
Post a Comment