Skip to content
Loading
how get filename the uploaded from array and save filename
this method work but can't get file name from input because file input create in run time
 
 
  1. //get filename the uploaded    
  2.  files: any[];    
  3.      
  4.  onClickUploadDocument(event){    
  5.      console.log("clicked");    
  6.      var file = event.target.files;    
  7.      this.files = []; // clear the array before pushing your values into it.    
  8.    
  9.    //  console.log(file);    
  10.      for (let i = 0; i < file.length; i++) {    
  11.        let fileInfo = file[i];    
  12.      //  console.log(fileInfo);    
  13.        this.files.push(fileInfo);    
  14.   }
  15.  }    
  1. "file" id="uploadFile" style="display: none" (change)='onClickUploadDocument($event)' multiple>  
  2. for="uploadFile" class="btn btn-primary">Upload Documents  
  3. "4" class="grid" >  
  4.   
  5. "let file of files ;let i = index">  
  6.  {{i}}  
  7. "text" name="id" #id="ngModel" [(ngModel)]=file.name>  
  8.   
  9.   
  10.   
  11.  

2 Replies

Know the answer? Post it — somebody with the same question will find it here.