From e56d80382337cd39088bfcc9b3ef2d4cf23285cc Mon Sep 17 00:00:00 2001 From: Dendy Faist Date: Mon, 10 Jul 2023 14:16:50 +0200 Subject: [PATCH] IMPL: Add tags on upload --- item.php | 3 ++- main.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/item.php b/item.php index e1c34a9..cd00f80 100644 --- a/item.php +++ b/item.php @@ -44,7 +44,7 @@ class Item implements JsonSerializable } // ::upload() requires the PHP file upload ARRAY from $_FILES - public static function upload(array $php_file): Item + public static function upload(array $php_file, string $tags): Item { $from_path = $php_file['tmp_name'] ?? null; @@ -57,6 +57,7 @@ class Item implements JsonSerializable // --- INITIALIZE --- $item = new Item(); $item->hash = hash_file('sha256', $from_path); + $item->tags = explode(' ', $tags); $item->extensionFromUpload($php_file); // --- ACTUALLY GRAB FILE --- diff --git a/main.php b/main.php index e2612e7..f213a8b 100644 --- a/main.php +++ b/main.php @@ -49,7 +49,7 @@ function get_item() function post_item() { // The checks are performed internally - $item = Item::upload($_FILES['file']); + $item = Item::upload($_FILES['file'], $_POST['tags']); return $item->getJson(); };