Property 'files' does not exist on type 'EventTarget' error in typescript

后端 未结 7 751
迷失自我
迷失自我 2020-11-30 09:50

I am trying to access the value of the input file from my ionic 2 application but still I\'m facing the issue of property files does not exist on type \'EventTarget\'. As it

7条回答
  •  我在风中等你
    2020-11-30 10:08

    This is more lines, but I think it's the clearest.

    const onChange = (event: Event) => {
      const target= event.target as HTMLInputElement;
      const file: File = (target.files as FileList)[0];
      /** do something with the file **/
    };
    

提交回复
热议问题