Get file name from input type file Angular2

后端 未结 6 1223
既然无缘
既然无缘 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条回答
  •  旧时难觅i
    2021-02-19 09:07

    This link's https://stackoverflow.com/a/44932086/4281182 solution suggested by @ Selçuk Cihan did not help so my workaround was to make the fileInput param type "any" by doing this

    fileEvent(fileInput){
        let file = fileInput.target.files[0];
        let fileName = file.name;
    }
    

    so in TS runtime this is a pure JS code

    Anyways thanks for this great ans it saved me a lot of time

提交回复
热议问题