aspose file tools*
The moose likes Struts and the fly likes File type and size Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "File type and size" Watch "File type and size" New topic
Author

File type and size

Mohamad Ibrahim
Greenhorn

Joined: Jun 26, 2007
Posts: 26
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

Joined: Jan 10, 2002
Posts: 60050
    
  65

"MoJava", please check your private messages for an important administrative matter.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
ujjwal soni
Ranch Hand

Joined: Mar 28, 2007
Posts: 403
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....


Cheers!!!
Ujjwal B Soni <baroda, gujarat, india> <+919909981973>
"Helping hands are better than praying lips......"
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: File type and size
 
Similar Threads
Regarding Upload a file
Struts2: How to do file upload validation programatically ?
How to upload only image file
File type and size
ENCTYPE=multipart/form-data , input type=file