Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap 4 right to left custom file input

i am trying to make the upload file input direction from bootstrap 4 right to left but nothing i tried so far worked

i also tried to change the direction for different tags

<div class="form-group">
        <div class="col-md-4">
            <div class="custom-file">
                <input type="file" class="custom-file-input" id="customFile" multiple lang="ar" dir="rtl">
                <label class="custom-file-label text-left" for="customFile">choose files to upload</label>
            </div>
        </div>
        <script type="text/javascript">
            $('.custom-file input').change(function (e) {
                var files = [];
                for (var i = 0; i < $(this)[0].files.length; i++) {
                    files.push($(this)[0].files[i].name);
                }
                $(this).next('.custom-file-label').html(files.join(', '));
            });
        </script>
    </div>

bootstrap upload file control style

like image 376
Ahmed Mohammed Avatar asked Jan 01 '19 15:01

Ahmed Mohammed


People also ask

How do I customize Bootstrap input?

To create a custom file upload, wrap a container element with a class of . custom-file around the input with type="file". Then add the . custom-file-input to it.

How do I select a file in Bootstrap?

Compose Bootstrap's custom file input with custom label. Hide default Choose file button with the ::file-selector-button pseudo-element. There are pseudo-elements ::-webkit-file-upload-button and ::-ms-browse for older versions of Chrome/Opera/Safari and Edge/IE respectively.


1 Answers

You would need a little custom CSS like this...

.custom-file-label::after {
    left: 0;
    right: auto;
    border-left-width: 0;
    border-right: inherit;
}

Demo: https://www.codeply.com/go/kOURGBHqEX

like image 157
Zim Avatar answered Sep 29 '22 23:09

Zim