Get only file name from file input on internet explorer

前端 未结 3 1915
孤独总比滥情好
孤独总比滥情好 2021-02-09 06:33

I need to return only the file name from an HTML input file.


The JavaScript code im using to get

3条回答
  •  灰色年华
    2021-02-09 07:11

    You can try this

    var path = document.getElementById("whatever").value;
    var fileName = path.match(/[^\/\\]+$/);
    console.log(fileName);
    

提交回复
热议问题