尝试再次上传时如何使用ng-file-upload保留以前上传的文件?

时间:2017-04-11 06:22:21

标签: javascript angularjs file-upload upload ng-file-upload

我已经实现了ng-file-upload指令将我的文件上传到相应的URL .....当我选择文件时,根据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>

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));
  });});

1 个答案:

答案 0 :(得分:0)

为什么不创建数组并在每次上传文件时推送它

methodABC(intValues);