Rename file on upload hook


I’m trying to rename files on upload (Site name + page title + number) but unfortunately this doesn’t work :confused:

Maybe someone has any good tips?

'hooks' => [
	     'file.create:after' => function ($file) {
		      $page = $file->page();
		      $title = $page->title();
              $count = $page->files()->count() + 1;	
              $filename = "Something-" . $title . "-" . $count;
		      try {
		          } catch(Exception $e) {

(It’s the latest Kirby build.)


Doesn’t it work at all or only when uploading multiple files at once?

Unfortunately not at all :confused:

Try with changeName() instead, rename() has been deprecated.

(That explains why it did somehow work with the previous Kirby version.)
Thanks a lot!
Stay healthy!