Redirect after file has been created

Hi,

i’d like to redirect to the image file after the file has been uploaded in the panel. As our authors has to provide many additional information per uplooaded image i’d like somewhat “force” them to fill out all fields proovided by the special file template.

My current attempt leads to an error (The file could not be uploaded):

image

I used the following hook:

    'hooks' => [
        'file.create:after' => function ($file) {
            try {
                $created = date('Y-m-d H:i:s');
                $file->update(
                    [
                        'created' => $created,
                    ]
                );

                go('files/'.$file->name());

                //return true;
            } catch (Exception $e) {
                return $e->getMessage();
            }
        }
    ]

Any idea what i missed here?

Thanks in advance,

Thomas E.-E.

It’s not possible to redirect from the hook.

thanks for the quick reply! Any other option to go? UseCase is: redirect after a file has been uploaded. Pretty much the same as redirect to parent once an image has been deleted :slight_smile:

I’m not aware of a way to achieve this. Another thing to keep in mind is that users can upload multiple files at once, so where would you redirect too?

Yes, but that happens on the client side (while the hook is executed on the server).