SO - 22219011
by Arun P Johny
HTML
<input id="id_file_field" name="file_field" type="file" style="display:none" />
<button id="upload_file">Click</button>
JavaScript
$(document).ready(function () {
$("#upload_file").click(function () {
$("#id_file_field").trigger('click');
});
$('#id_file_field').change(function () {
var value = this.value;
var fileName = typeof value == 'string' ? value.match(/[^\/\\]+$/)[0] : value[0]
console.log(fileName);
})
});