I am developing angularjs application where I have multiple file upload dynamically. Let me explain the scenario. I will get required list of documents in API. I will bind as below.
<div class="upload-button" ng-repeat="file in files">
<div class="upload-button-icon">
<img src="images/folder-small.png">
<div class="upload-text">{{file}}</div>
<input type="file" id="file1" name="file1" />
</div>
</div>
<div class="button-container margin-top80">
<input type="submit" value="{{ 'Save' | translate }}" ng-click="uploadFiles()" class="blue-button">
</div>
I have tried as below.
$scope.upload = function () {debugger;
alert($scope.files.length + " files selected ... Write your Upload Code");
var fileuploadurl = baseurl + 'api/Customer/UploadLeaseFiles/' + LoginID + '/' + "GOSI";
for (var i = 0; i < $scope.files.length; i++) {
var $file = $scope.files[i];
$upload.upload({
url: fileuploadurl,
file: $file,
progress: function (e) {
// wait...
}
})
.then(function (data, status, headers, config) {
alert('file is uploaded successfully');
});
}
alert('file is uploaded successfully');
};
This code is giving me error eferenceError: $upload is not defined.
I want to submit these files to API. May I know how can I do this? Any help would be greatly appreciated. Thank you.