codyswanner / Meme-Cataloger

Learning ReactJS and Django while building something that I want to use
1 stars 1 forks source link

Validation for upload file types #41

Closed codyswanner closed 4 months ago

codyswanner commented 4 months ago

When a user attempts to upload a file, UploadForms accepts incorrect, non-image file types (ie, .txt files) to the form. Implement validation for file types, and if possible reject unsupported file types from the form.

codyswanner commented 4 months ago

See issue #42: work on one of these issues may inform work on the other.

codyswanner commented 4 months ago

Client side allows strong suggestion for accepted file types, but cannot outright reject unaccepted file types if a user insists on attempting to upload them. See the Mozilla docs on HTML input tag:

"The accept attribute doesn't validate the types of the selected files; it provides hints for browsers to guide users towards selecting the correct file types. It is still possible (in most cases) for users to toggle an option in the file chooser that makes it possible to override this and select any file they wish, and then choose incorrect file types."

The server, on the other hand, can outright reject a request that includes unacceptable file types, and does so in #45, which sufficiently addresses this issue.