onUploadError

When I upload a wrong file type intentionally I get this error (image). I wanted to display in the UI that the user is trying to upload an invalid file type.
No description
2 Replies
Danny
DannyOP•7mo ago
I get the same error when trying to upload an image over size limit. Am I suppose to get that error on the client? I get this on the server (image) which is what I would like to show the user invalid file type/size etc. 👀
No description
rv0
rv0•7mo ago
Hey you should definitely get that error on your client! Browsers wouldnt normally let sites use the files on your computer for security reasons, so theyll only allow you to do so when youve used a file input to select those files. That also means that your browser will play a forwarding role during the upload. A POST request with the file in the body is sent to the receiver (currently your localhost, eventually UploadThing) and because of certain rules, the upload is declined. This comes back in the form of a HTTP response, which has a status code in the 400-499 range. Browsers will generally display the error in a console.error(msg) format.
Want results from more Discord servers?
Add your server