summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2025-10-05 20:53:56 +0500
committerilotterytea <iltsu@alright.party>2025-10-05 20:53:56 +0500
commitcf4d0517e831ed713bbc345abb7fcb8dc221547d (patch)
treed37407fb23672e1dd5b106a7eb02bcd233122a6a
parent5f04ed73f60c6e71cbae2b88a28d76e81df64a3d (diff)
fix: file extension was duplicated in filename on download
-rw-r--r--public/index.php7
1 files changed, 5 insertions, 2 deletions
diff --git a/public/index.php b/public/index.php
index 2ee42ae..f4d8e51 100644
--- a/public/index.php
+++ b/public/index.php
@@ -139,6 +139,10 @@ if (FILE_CATALOG_FANCY_VIEW && $file_id) {
$file['size_formatted'] = sprintf("%.2f", $size / pow(1024, $factor)) . ' ' . $units[$factor];
$file['name'] = $file['title'] ?? sprintf('%s.%s', $file['id'], $file['extension']);
+ $file['download_name'] = $file['name'];
+ if (!str_ends_with($file['download_name'], ".{$file['extension']}")) {
+ $file['download_name'] .= ".{$file['extension']}";
+ }
$file['resolution'] = [];
@@ -249,8 +253,7 @@ $privacy_exists = is_file($_SERVER['DOCUMENT_ROOT'] . '/static/PRIVACY.txt');
<a href="<?= $file['full_url'] ?>">
<button>Full size</button>
</a>
- <a href="<?= $file['full_url'] ?>"
- download="<?= sprintf('%s.%s', $file['name'], $file['extension']) ?>">
+ <a href="<?= $file['full_url'] ?>" download="<?= $file['download_name'] ?>">
<button>Download</button>
</a>
</div>