How to check if filename uploaded, already exists?
I am trying to prevent the user, from uploading a file that already exists with the same name. How can I prevent them from doing so?
1 Reply
If you're preserving the original filenames, you could use
->rules()
and then write a Closure which checks the name of the files in the storage.
In the closure you could use Storage::disk('your_disk')->exists('file.ext');
Before doing that, read this:
https://filamentphp.com/docs/3.x/forms/fields/file-upload#security-implications-of-controlling-file-names
there are several security implications for why you don't want to preserve original filenames.
Good coding! π