Get file name from input type file Angular2

后端 未结 6 1183
既然无缘
既然无缘 2021-02-19 08:33

I want get the file name from my html input tag in a modal view and save it using Angular2. Can someone help me?

6条回答
  •  不要未来只要你来
    2021-02-19 08:48

    This work form me:

    HTML

    
    
    Seleccionado: {{ fileName }}

    TS

    selectedFiles: FileList;
    fileName: string;
    
    detectFiles(event) {
        this.selectedFiles = event.target.files;
        this.fileName = this.selectedFiles[0].name;
        console.log('selectedFiles: ' + this.fileName );
      }
    

提交回复
热议问题