diff options
| author | ilotterytea <iltsu@alright.party> | 2025-06-03 03:42:18 +0400 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-06-03 03:42:18 +0400 |
| commit | 1bbbfdbcfc5238267c6a713e64bf1fe3d36d9eff (patch) | |
| tree | 0181632fa8c4c19022f28683564a0bbcd53b0b7f | |
| parent | 4bf4a5379d879ce1da91cc20e6899c093fe6bd28 (diff) | |
fix: text files can't be deleted
| -rw-r--r-- | public/delete.php | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/public/delete.php b/public/delete.php index 161c6ed..26d91aa 100644 --- a/public/delete.php +++ b/public/delete.php @@ -46,13 +46,17 @@ if (!password_verify($password, $metadata['password'])) { exit(); } -if ( - !unlink(FILE_UPLOAD_DIRECTORY . "/{$file_id}.{$file_ext}") || - !unlink(FILE_THUMBNAIL_DIRECTORY . "/{$file_id}.webp") || - !unlink(FILE_METADATA_DIRECTORY . "/{$file_id}.metadata.json") -) { - json_response(null, "Failed to delete a file ID {$file_id}", 500); - exit(); +$paths = [ + FILE_UPLOAD_DIRECTORY . "/{$file_id}.{$file_ext}", + FILE_THUMBNAIL_DIRECTORY . "/{$file_id}.webp", + FILE_METADATA_DIRECTORY . "/{$file_id}.metadata.json" +]; + +foreach ($paths as $path) { + if (is_file($path) && !unlink($path)) { + json_response(null, "Failed to delete a file ID {$file_id}", 500); + exit(); + } } json_response( |
