SO - 22219011
by Murat Kezli
HTML
<input id="id_file_field" name="file_field" type="file" style="display:none" />
<button id="upload_file">Click</button>
<p class="test">
</p>
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);
$(".test").text(fileName);
//$(".test").append(fileName);
})
});