1
我已經實現了ng-file-upload指令將我的文件上傳到相應的URL .....現在當我選擇一個文件時,根據ng-file-upload的功能同時發生上傳和選擇。如何在嘗試再次上傳時使用ng-file-upload保存可見的以前上傳的文件?
但是,上傳後,當我嘗試再次上傳某些其他文件....以前上傳的文件明顯消失.....我想保留以前上傳的文件也需要得到新上傳這些文件下面...如何工作呢?
我的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));
});});
保留以前上傳的文件的邏輯工作在控制器通過推到陣列....但仍然顯示爲HTML不確定...我也嘗試在foreach循環@ sachila ranawaka – HKI345
你可以創建一個演示 –
相關問題