This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes uploading only .doc files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "uploading only .doc files" Watch "uploading only .doc files" New topic
Author

uploading only .doc files

khushi paul
Greenhorn

Joined: Feb 08, 2005
Posts: 26
hi all,
i am using apache jakarta commons fileupload for uploading files.
everything goes well but i want to restrict my users to upload .doc file only.what shud i do for that?any suggestions?
if possible pls provide example code.
thanks & regards
Khushi
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
You'll need to analyse the actual data streams and determine whether they're the filetype you want or not.

Dumb filters work on file extension. This is easy, just check if the filename ends with what you're looking for. Of course this doesn't work as I could just rename a file to have the extension you want (this is the way email virusses try to trick people).


42
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: uploading only .doc files
 
Similar Threads
Need to Convert Documents to HTML
SFTP in a Java application
A good, easy beginner's tutorial on uploading files through JSP
HttpClient file upload code review
how upload all files in a local folder to server