尝试再次上传时如何使用 ng-file-upload 明显保留以前上传的文件?
How to retain visibly previous uploaded files using ng-file-upload when tried to upload again?
我已经实施了 ng-file-upload 指令将我的文件上传到相应的 URL.....现在当我 select 一个文件同时上传和 select根据 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));
});});
你为什么不创建一个数组并在每次上传文件时推送到它
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));
});
});
}
我已经实施了 ng-file-upload 指令将我的文件上传到相应的 URL.....现在当我 select 一个文件同时上传和 select根据 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));
});});
你为什么不创建一个数组并在每次上传文件时推送到它
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));
});
});
}