diff options
| author | ilotterytea <iltsu@alright.party> | 2025-06-08 02:36:28 +0400 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-06-08 02:36:28 +0400 |
| commit | 84ad6e3c5b2f74b82d17b289db62cdf88f18a95b (patch) | |
| tree | ee9f41196bdf9b07abf03eae75d212ab75ffdcb1 /public/upload.php | |
| parent | 6ffd0fa47e5fdcb6d7345c35605338f096de3276 (diff) | |
feat: file title
Diffstat (limited to 'public/upload.php')
| -rw-r--r-- | public/upload.php | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/public/upload.php b/public/upload.php index 6bff34f..a0810ef 100644 --- a/public/upload.php +++ b/public/upload.php @@ -27,6 +27,10 @@ if (!is_dir(FILE_UPLOAD_DIRECTORY) && !mkdir(FILE_UPLOAD_DIRECTORY, 0777, true)) try { $preserve_original_name = boolval($_POST['preserve_original_name'] ?? '0'); + $title = str_safe($_POST['title'] ?? '', FILE_TITLE_MAX_LENGTH); + if (empty(trim($title))) { + $title = null; + } $url = isset($_POST['url']) ? $_POST['url'] ?: null : null; $file = isset($_FILES['file']) ? $_FILES['file'] ?: null : null; @@ -209,7 +213,11 @@ try { $file_data['views'] = 0; $file_data['uploaded_at'] = time(); - if ($preserve_original_name) { + if ($title) { + $file_data['original_name'] = $title; + } + + if ($preserve_original_name && !$title) { if ($file && !empty($file['name'])) { $file_data['original_name'] = $file['name']; } else if ($url) { |
