I have implemented ng-file-upload directive to upload my files to the respective URL.....for now when I select a file both upload and select is happening simultaneously according to the functionality of ng-file-upload.
But,After the upload when i try to again upload certain other files....the previously uploaded files are vanishing visibly.....i want to retain the previous uploaded files too and need to get the newly uploaded files below those...how can work on this?
My html
<form>
<input type="text" class="browse-form"placeholder=" Click browse to load documents " required>
<button ngf-select="vm.uploadFiles($files)" multiple accept=".csv,.pdf,.doc,.docx,.xlsx" class="btn btn-info btn-md">Browse</button>
</form>
<p style="margin-top: -30px;"> Note:Supported file formats are word,excel and pdf only</p>
<table class="table table-fixed">
<thead class="table-header"><tr>
<th class="col-xs-6">DOCUMENT NAME</th>
<th class="col-xs-1">SIZE</th>
<th class="col-xs-1">VERSION</th>
<th class="col-xs-2">DATE UPLOADED</th>
<th class="col-xs-2">UPLOADED BY</th>
<th class="col-xs-1">ACTION</th></tr>
</thead>
<tbody>
<tr ng-repeat="uploading in vm.files track by $index" style="font:smaller">
<td>{{uploading.name}}</td>
MY controller.js
vm.uploadFiles = function(files){
vm.files = files;
angular.forEach(files,function(file){
file.upload = Upload.upload({
url:' ',
data:{file:file}
});
file.upload.then(function(response){
$timeout(function(){
file.result = response.data;
});
},
function (response) {
if (response.status > 0)
vm.errorMsg = response.status + ': ' + response.data;
},
function (evt) {
file.progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
});});
why don't you create an array and push to it each time file is uploaded
vm.fileArr = []
vm.uploadFiles = function(files) {
vm.files = files;
angular.forEach(files, function(file) {
vm.fileArr.push(file)// show this array
file.upload = Upload.upload({
url: ' ',
data: {
file: file
}
});
file.upload.then(function(response) {
$timeout(function() {
file.result = response.data;
});
},
function(response) {
if (response.status > 0)
vm.errorMsg = response.status + ': ' + response.data;
},
function(evt) {
file.progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
});
});
}