aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes upload txt files only Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply locked New topic
Author

upload txt files only

priyanka jolly
Greenhorn

Joined: Oct 31, 2006
Posts: 9
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

Joined: Apr 26, 2007
Posts: 111

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


Regards, Abdul Mohsin
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
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.


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
 
Don't get me started about those stupid light bulbs.
 
subject: upload txt files only