F
Filamentβ€’6mo ago
gemini.dev

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?
No description
1 Reply
Davide Cariola
Davide Cariolaβ€’6mo ago
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! πŸ˜„
Want results from more Discord servers?
Add your server