Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
Java has nothing to do with it. It all happens on the client side, in the browser.
Here is all the information: https://developer.mozilla.org/ru/docs/Web/HTML/Ele...
Hello!
If the code should work in the browser, then you need to validate using html or js.
If you
need validation using html, then there is an accept attribute for the
input htmlbook.ru/html/input/accept
accept only images: <input type="file" name="img" accept="image/*">
But if you need server-side validation, then that's different...
You can connect Apache Common Utils
https://commons.apache.org/proper/commons-io/
And then check the MIME type of the file and if it doesn't match the desired type, then return some message to the client that the file type is incorrect
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question