Get filename from input [type='file'] using jQuery

前端 未结 11 1027
陌清茗
陌清茗 2020-12-23 20:15

This is the uploaded form.

11条回答
  •  一生所求
    2020-12-23 20:20

    Using Bootstrap

    Remove form-control-file Class from input field to avoid unwanted horizontal scroll bar

    Try this!!

    $('#upload').change(function() {
        var filename = $('#upload').val();
        if (filename.substring(3,11) == 'fakepath') {
            filename = filename.substring(12);
        } // For Remove fakepath
        $("label[for='file_name'] b").html(filename);
        $("label[for='file_default']").text('Selected File: ');
        if (filename == "") {
            $("label[for='file_default']").text('No File Choosen');
        }
    });
    .custom_file {
      margin: auto;
      opacity: 0;
      position: absolute;
      z-index: -1;
    }
    
    
    

提交回复
热议问题