tinyfilemanager icon indicating copy to clipboard operation
tinyfilemanager copied to clipboard

Add a new feature download all selected files for tinyfilemanager

Open BoneDeath opened this issue 3 years ago • 4 comments

Hi, it would be great to add a button to download all selected files so you don't have to download them one by one asdasd

BoneDeath avatar Oct 18 '22 04:10 BoneDeath

This code is no longer valid apparently, so this should either be adapted to current code or closed.

ner00 avatar Mar 26 '23 01:03 ner00

This code is no longer valid apparently, so this should either be adapted to current code or closed.

Hi Thanks for telling me, I just resolve to current code

BoneDeath avatar Aug 01 '23 09:08 BoneDeath

This does not appear to work.

The first issue is that you placed the JavaScript function inside an if statement that only runs when in editor mode, so that would never work in the file list where it should, instead you get an error downloadSelected is not defined.

Then, even if you place the function somewhere appropriate, it still does not work. Instead, it just calls/clicks the download button for the last file you selected, which then triggers the confirmDailog download modal and after that you're stuck with the modal-backdrop in the foreground and can't interact with the file list anymore nor does it download more than 1 file.

ner00 avatar Aug 02 '23 19:08 ner00

Instead of using the download button, which triggers the modal and also has multiple hurdles (path and filenames with + symbol replacing spaces being one of them), it would be much easier to use the existing Direct Link object. This seems to work:

        //download selectedFiles
        function downloadSelected() {
            parent = $("input:checked").closest("tr");
            child = parent.find("a[title='<?php echo lng('DirectLink')?>']");

            var a = child;
            for (var i = 0, iLen = a.length; i < iLen; i++) {
                a[i].setAttribute("download", "");

                if (a[i].click) {
                    a[i].click();
                } else {
                    $(a[i]).click();
                }

                a[i].removeAttribute("download");
            }
        }

P.S: The code still has to be placed outside the editor conditional if, you can for example, place it right after it closes: https://github.com/prasathmani/tinyfilemanager/blob/eb8f3d80bcf27f93c5d9e800d60231b1617536b1/tinyfilemanager.php#L4217

    <script>
        //download selectedFiles
        function downloadSelected() {

ner00 avatar Aug 02 '23 21:08 ner00