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.
2 Replies
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. 👀
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.