Disable multiple file select in elFinder

1.3k views Asked by At

We are using elFinder for our software, and also using its file picker.

This is the (actually working) code:

var elfinderInstance = modalBody.elfinder({
    lang: 'de',
    [...],
    getFileCallback: function(data) {
        $("#" + fileInputId).val(data.url);
        fileModal.modal("hide");
    },
    handlers : {
        select : function(event, elfinderInstance) {
            console.log(event.data.selected);
            var selected = event.data.selected;

            if (selected.length) {
                selectedElement = elfinderInstance.url(selected[0]);
            }
        }
    }
}).elfinder('instance');

However it is possible to select multiple files in the modal, by simply pressing the CTRL button and clicking on multiple files.

How can I disable this behaviour?

I already checked the select handler, and selected.length already returns the number of selected files but I can't figure out how to unselect the previously selected files so that only one file can be selected. I also found nothing in the Docs (https://github.com/Studio-42/elFinder/wiki).

1

There are 1 answers

0
nao-pon On

With elFInder 2.1.17 or higher, the connector main option maxTargets is available. This is an option to suppress the load on the connector side, but it is also effective for this case.

$opts = array(
    'maxTargets' => 1,
    'roots' => array( .... ),
);

see https://github.com/Studio-42/elFinder/issues/2334