diff options
| author | ilotterytea <iltsu@alright.party> | 2025-10-05 20:53:56 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-10-05 20:53:56 +0500 |
| commit | cf4d0517e831ed713bbc345abb7fcb8dc221547d (patch) | |
| tree | d37407fb23672e1dd5b106a7eb02bcd233122a6a | |
| parent | 5f04ed73f60c6e71cbae2b88a28d76e81df64a3d (diff) | |
fix: file extension was duplicated in filename on download
| -rw-r--r-- | public/index.php | 7 |
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> |
