I need to allow the user to upload only text files(.txt,.doc,.rtf etc).
How can i validate the uploaded files contains only text data.
I need to validate the data in the file not the file extension.
If the user uploads any Image or video files etc other than text files I need to display like
“The format of the file you uploaded doesn’t match the format required”
You can try to use Apache Tika library. It can find out type of a file by its content.