Hi I am writing a code to allow only txt files to upload.I have written a javascript to allow only .txt files to upload.But if the user gets cranky and renames an exe file to .txt file then on upload i have to prevent it as it results in uploading of junk data Can you please let me know is there a way to know the content type of the file being loaded or any other way i can prevent it. i am using commons-file upload jar
On linux, there is the file program, to test files, and I guess, there is a win32-port of this program too, but you might do it yourself by parsing the bytes and rejecting junk. Only few of the lower bytes 0-31 are legal in 'text'-files, as \n, \t, \r.