IMPL: Add tags on upload
This commit is contained in:
parent
147d33d299
commit
e56d803823
3
item.php
3
item.php
|
@ -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 ---
|
||||||
|
|
2
main.php
2
main.php
|
@ -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();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue