Can the maxFileCount of the bootstrap fileinput upload control be dynamic?

now use the bootstrap fileinput control to upload files, for example, only 10 files can be uploaded to, maxFileCount: 10, but after users upload 4 files, how does the maxFileCount in option become 6 dynamically? MaxFileCount:6

Mar.15,2021

what I know is that you need a plug-in to do it. http://plugins.krajee.com/fil.

<input value="" name="check_nums" class="check_nums">

$(document).on('ready', function() {
    var check_nums = $(".check_nums").val();
    $('-sharpfile-th').fileinput({
        showUploadedThumbs: false,
        language: 'th',
        uploadAsync: false,
        maxFileCount: check_nums, 
        resizePreference: 'height',
        resizeImage: true,
        overwriteInitial: false,
        validateInitialCount: true,
        showUpload: false,    
        allowedFileExtensions: ['jpg', 'png', 'jpeg'],
        previewSettings: {
            image: {width: "auto", height: "100px"},
            object: {width: "213px", height: "160px"},
        },
        layoutTemplates: {
            actions: '<div class="file-actions">\n' +
                '    <div class="file-footer-buttons">\n' +
                '        {delete}' +
                '    </div>\n' +
                '</div>',
        }
    }).on("filebatchselected", function(event, files) {

    });
});
// 
$(".check_nums").change(function(){
    $("-sharpfile-th").fileinput('maxFileCount',$(this).val());
});

this practice has bug. If the limit has been reached, the maxFileCount will be 0, or even the previous historical data will be negative, resulting in invalid maxFileCount

.
Menu