• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

uploading only .doc files

 
khushi paul
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic