Muli Muli - 7 months ago 20
jQuery Question

Get file name with Jquery

I want to get the file name that i upload and show it in my

this is my code:

var filename = $('#image_file').val();

<div class="container-input-custom">
<div class="upload-btn">
<span id="select_file"></span>
<label for="file-upload"><i class="fa fa-ellipsis-h" aria-hidden="true"></i></label>
<input type="file" id="image_file">


This is some simple example. I hope this will help to you:

$(document).ready(function() {
  $("#image_file").on("change", function() {

Edit: Only now I realized what the problem is. So this is the code:

$(".upload-btn").one("click", function _handler(event) {
        _handler.oldContext = this;
        var _file = $(this).find("input[type='file']").one("change", function() {
        var oldContext =    $(_handler.oldContext);
        $(this).attr("display", "none");"click", _handler); 

and this is working jsfiddle:

Edit2: This is working example with two inputs and attach listeners on document ready.

Edit3: There is issues under Chrome and Chromium with fakepath. This is the last version.