UploadThing file accept type restriction
I'm trying to find how I can allow the
<UploadButton />
to only accept images for example with extensions of (.png
, .jpg
...etc).
Because currently my users are able to upload .gif
for example and I don't want to allow that.
I searched the docs but there is nothing regarding image type restriction or acceptation. Unless I missed something...Solution:Jump to solution
Thanks that solves it for me.
However if I used this I wont be able to set
maxFileSize
and maxFileCount
```tsx...3 Replies
you should be able to add a list of file types (also called MIME-types) in your Route Config in the file router. e.g.
myUploadButton: f(["image/jpeg", "image/png"
])
docs: https://docs.uploadthing.com/file-routes#route-configFile Routes - UploadThing Docs
File Routes is a core concept of UploadThing that defines what your users can upload
Solution
Thanks that solves it for me.
However if I used this I wont be able to set
maxFileSize
and maxFileCount
I solved it by checking the file size in the middleware