Hey!
I am having some issues with multiple file uploads and hooks.
Is there a way to check inside the hook
file.create:after' => function (Kirby\Cms\File $file) { }
if the current file was the last one uploaded?
Or is it better to use another hook for this purpose?
My situation:
I am trying to put different files, – after they have been uploaded – in different file fields… so it’s kind of sorting the files.
If I upload several files and use
$thispage = $thispage->update(array("teaser-video-poster" => $file->uuid()));
inside the hook, it works sometimes, but sometimes fields are left out.
Maybe it’s because I’m calling the update function too often and it’s causing api errors somewhere.
I think I need to collect all the files and fields in an array and after the last file is uploaded update the page.
Is that right?
Thank you!