We look the answer from @Grundy.
Javascript
document.querySelector('input').addEventListener('change', function() { var splittedFakePath = this.value.split('\\'); document.querySelector('div').textContent = splittedFakePath[splittedFakePath.length - 1]; });
<input type="file"> <div></div>
https://jsfiddle.net/xfynp30o/
jQuery
$('input').on('change', function() { var splittedFakePath = this.value.split('\\'); $('div').text(splittedFakePath[splittedFakePath.length - 1]); });
<script src="//ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> <input type="file"> <div></div>
https://jsfiddle.net/pxk8x599/
Regular Expression Option
You can add problems and do it with regular expressions:
document.querySelector('input').addEventListener('change', function() { document.querySelector('div').textContent = this.value.replace(/.*\\(.+)/, '$1'); });
<input type="file"> <div></div>
https://jsfiddle.net/bvk7xcw4/