[英]How to retain visibly previous uploaded files using ng-file-upload when tried to upload again?
我已經實現了ng-file-upload指令將我的文件上傳到相應的URL .....當我選擇文件時,根據ng-file-upload的功能同時進行上傳和選擇。
但是,上傳后,當我嘗試再次上傳某些其他文件....以前上傳的文件明顯消失.....我想保留以前上傳的文件,並需要獲取下面的新上傳的文件。 ..how可以這個嗎?
我的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>
我的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));
});});
你為什么不創建一個數組,並在每次上傳文件時推送它
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));
});
});
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.