IMPL: Add tags on upload

This commit is contained in:
Dendy 2023-07-10 14:16:50 +02:00
parent 147d33d299
commit e56d803823
2 changed files with 3 additions and 2 deletions

View File

@ -44,7 +44,7 @@ class Item implements JsonSerializable
} }
// ::upload() requires the PHP file upload ARRAY from $_FILES // ::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; $from_path = $php_file['tmp_name'] ?? null;
@ -57,6 +57,7 @@ class Item implements JsonSerializable
// --- INITIALIZE --- // --- INITIALIZE ---
$item = new Item(); $item = new Item();
$item->hash = hash_file('sha256', $from_path); $item->hash = hash_file('sha256', $from_path);
$item->tags = explode(' ', $tags);
$item->extensionFromUpload($php_file); $item->extensionFromUpload($php_file);
// --- ACTUALLY GRAB FILE --- // --- ACTUALLY GRAB FILE ---

View File

@ -49,7 +49,7 @@ function get_item()
function post_item() function post_item()
{ {
// The checks are performed internally // The checks are performed internally
$item = Item::upload($_FILES['file']); $item = Item::upload($_FILES['file'], $_POST['tags']);
return $item->getJson(); return $item->getJson();
}; };