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

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -