Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

File type and size

 
Mohamad Ibrahim
Greenhorn
Posts: 27
  • 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: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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
  • 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....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic