Get only file name from file input on internet explorer

前端 未结 3 1914
孤独总比滥情好
孤独总比滥情好 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:18

    I hope this works.

    var fullFileName = document.getElementById("whatever").value;
    var fileName = fullFileName.substr(fullFileName.lastIndexOf("\\")+1, fullFileName.length);
    

    Here is the fiddle for that Fiddle

提交回复
热议问题