An image file input still needs validation when it has an accept attribute. The attribute supplies a picker hint; it does not verify the chosen file.
For an image form, accept="image/*" can make selection easier, while the application still needs to check the file it receives. Keep the destination's supported formats explicit in the interface instead of treating the broad image filter as its complete policy.
Validate the expected requirement on the server too. Keep server validation in place when adding a client-side selection check. If the destination rejects a file, preserve its error rather than treating the presence of an image extension as proof of acceptance.
Test a supported sample and a deliberately unsuitable sample through the same form. Record the selected filename and the actual response for each attempt.
Source: MDN accept.
I work on Morphio, and this note is part of the image-workflow guidance I maintain.
Top comments (0)