From 5cdc89d4c1da58098743d2717363560f6fe0e64b Mon Sep 17 00:00:00 2001
From: Blaubeeree <47636067+Blaubeeree@users.noreply.github.com>
Date: Fri, 30 May 2025 21:16:27 +0000
Subject: [PATCH] add download for folders
---
tinyfilemanager.php | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/tinyfilemanager.php b/tinyfilemanager.php
index d1848d9..24a2ea4 100644
--- a/tinyfilemanager.php
+++ b/tinyfilemanager.php
@@ -932,6 +932,22 @@ if (isset($_GET['dl'], $_POST['token'])) {
// Call the download function
fm_download_file($path . '/' . $dl, $dl, 1024); // Download with a buffer size of 1024 bytes
exit;
+ } else if ($dl != '' && is_dir($path . '/' . $dl)) {
+ chdir($path);
+
+ // zip the directory
+ $zipname = sys_get_temp_dir() .'/'. $dl;
+ $zipper = new FM_Zipper();
+ $res = $zipper->create($zipname, $dl);
+
+ if ($res) {
+ // download the zip file and delete it afterwards
+ fm_download_file($zipname, $dl . '.zip', 1024);
+ unlink($zipname);
+ } else {
+ fm_set_msg(lng('Error while creating Archive'), 'error');
+ }
+ exit;
} else {
// Handle the case where the file is not found
fm_set_msg(lng('File not found'), 'error');
@@ -2208,6 +2224,7 @@ $all_files_size = 0;
+