javascript - Get only file name from file input on internet explorer -
i need return file name html input file.
<input type="file" id="whatever" />
the javascript code im using name of file is:
document.getelementbyid("whatever").value;
in firefox gives file name want, in ie full path.
i think string manipulation way name.
what easiest/shortest way name (extension too) in javascript? thanks.
you can try
var path = document.getelementbyid("whatever").value; var filename = path.match(/[^\/\\]+$/); console.log(filename);
Comments
Post a Comment