I used this:
$(\'input[type=file]\').val()
to get the file name selected, but it returned the full path, as in \"C:\\fakepath\\filename.doc
We can also remove it using match
match
var fileName = $('input:file').val().match(/[^\\/]*$/)[0]; $('#file-name').val(fileName);