You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Daniel Kies <da...@gmail.com> on 2006/01/16 19:44:06 UTC

FormFile file type validation

Does anyone know of a validator that can be plugged into the validator
framework that will check file types for FormFile?  This would be so a user
can't upload certain extensions like .exe and the application will catch it.

thanks.

Re: FormFile file type validation

Posted by Laurie Harper <la...@holoweb.net>.
Daniel Kies wrote:
> Does anyone know of a validator that can be plugged into the validator
> framework that will check file types for FormFile?  This would be so a user
> can't upload certain extensions like .exe and the application will catch it..

There's nothing in the standard set of validation rules that would do 
this, so you'd have to implement your own validation rule. That 
shouldn't be too hard to do, whether based just on file name extension 
or using something more sophisticated like the lib David mentioned, but 
it does still require a custom extension to the validator framework.

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Unsubsribe

Posted by sa...@centrelink.gov.au.
I would like to unsubscibe to this user group...How do I do!!!!

Cheers

______________________________________________________________________________________

Saran.k
J2EE Developer
Refresh 1.13 - Org Central
EW1, TOP, Athllon Drive
Tuggeranong ACT 2901
Phone:
Fax:
Email:
Website:
(02) 6244 1374 (sp. 441374)
(02) 6244 7951 (sp. 447951)
 Saran.Kalimoorthy@centrelink.gov.au
http://centrenet/homepage/divfamily/brcsrel/orgcentral/index.htm
______________________________________________________________________________________

 
 

**********************************************************************
IMPORTANT:  This e-mail is intended for the use of the addressee and may contain information that is confidential, commercially valuable or subject to legal or parliamentary privilege.  If you are not the intended recipient you are notified that any review, re-transmission, disclosure, use or dissemination of this communication is strictly prohibited by several Commonwealth Acts of Parliament.  If you have received this communication in error please notify the sender immediately and delete all copies of this transmission together with any attachments.
**********************************************************************


RE: FormFile file type validation

Posted by "David G. Friedman" <hu...@ix.netcom.com>.
Daniel,

I remembered reading about a Java class which could do that using a file's "magic numbers."  I think this library was
the one I am thinking about.  Using it, you could determine the file information in your Form bean, I think.  It was
called "ffident — Java metadata extraction / file format identification library."

URL: http://schmidt.devlib.org/ffident/index.html

=== Example: ===
File file = new File("filename");
FormatDescription desc = FormatIdentification.identify(file);
if (desc == null) {
  System.out.println("Unknown format.");
} else {
  System.out.prinlnt("Format=" + desc.getShortName() + ", MIME type=" + desc.getMimeType());
}
=== ===

Warning: If LGPL licenses bother you, don't use it.

Regards,
David

-----Original Message-----
From: Daniel Kies [mailto:danielkies@gmail.com]
Sent: Monday, January 16, 2006 1:44 PM
To: user@struts.apache.org
Subject: FormFile file type validation


Does anyone know of a validator that can be plugged into the validator
framework that will check file types for FormFile?  This would be so a user
can't upload certain extensions like .exe and the application will catch it.

thanks.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org