Bookmark Topic Watch Topic
  • New Topic

upload txt files only

 
priyanka jolly
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
 
Abdul Mohsin
Ranch Hand
Posts: 111
Java Linux Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi,

just giving you an idea , just get the content and check using unicode values that they are normal charecters(a-z A-Z) or numbers (0-9) if some special charecters are there then don't allow them.

Abdul Mohsin
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
Nothing to do with SCJP here. Send a PM to a moderator when you can think of the right forum for your topic. Then we will move it for you.
 
It is sorta covered in the JavaRanch Style Guide.
    Bookmark Topic Watch Topic
  • New Topic