Side note, this is very unsafe:
$extension = $file->getClientOriginalExtension();
https://symfonycasts.com/screencast/symfony-uploads/file-naming#play
https://symfonycasts.com/screencast/symfony-uploads/upload-in-form#play
https://symfonycasts.com/screencast/symfony-uploads/uploader-service#play
Also in the laravel documentation:
However, keep in mind that the getClientOriginalName and getClientOriginalExtension methods are considered unsafe, as the file name and extension may be tampered with by a malicious user. For this reason, you should typically prefer the hashName and extension methods to get a name and an extension for the given file upload:
Reference:
https://laravel.com/docs/12.x/filesystem#other-uploaded-file-information