File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

File type and size

 
Mohamad Ibrahim
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to check the file type and size when i upload it using jsp and struts .
For example, i don't want the user to upload the exe files or the file is bigger than 10mb .
Thanks for help..
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64171
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"MoJava", please check your private messages for an important administrative matter.
 
ujjwal soni
Ranch Hand
Posts: 403
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

You can do this quite easily using struts file upload. check out the below code:


*************Action File



****************Struts config file



*****For file type, you can substring the string of file name with last 3 characters excluding dot, it will give you the file extension, alternatively, you can get it from the content type also. The upload class offers many other functionalities. Thats it....
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic