How to show the uploaded filename in the File field type using bootstrap 4


« Back to overview

In the Symfony bootstrap_4_layout.html.twig, if you upload a file the filename is not displayed in the field.
You need additional javascript for this:


 $('.custom-file-input').on('change',function(){
        var fileName = $(this).val().replace(/.*(\/|\\)/, '');
        $(this).next('label').addClass("selected").html(fileName);
    });