I was beginning to think this might be the case. I guess it is time to brush up on my javascript :)
Hopefully by the time I get the client side validation done, someone will come up with a solution to get the server side validation for the html:file to work. Apparently it works for J�rg but I am not sure which version of struts he is running...
-Joey
Claude Betancourt wrote:
Joey,
Since you need to cover your butt on both sides, client and server, do a
simple javascript validation on the form as it is being submitted to make
sure something was entered in the file input field.
function validateUploadForm(theForm) {
if (theForm.myFile.value=="") {
alert("Please select a file to upload from your workstation by clicking
the Browse button.");
theForm.myFile.focus();
return false;
}
}
After that, your action should be smart enough to check for any of the
obvious file (FileInputStream) properties, like contentType, fileName or
fileSize (to be >0). Look at the API for java.io.FileInputStream
-c
----- Original Message -----
From: "Joey Ebright" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Sunday, February 09, 2003 8:33 PM
Subject: Re: Problem with empty file upload field
What happens if the user does not specify a file to upload and you
submit the form? Do you get an error? How do you handle this?
J�rg Maurer wrote:
Just for info - I use struts 1.3b nb and built upload func into my
current app - no problem. Remark what i corrected from wrong in first
step :
1. <html:form action="...enctype="multipart/form-data"> <- !!!!!!
2. use as property a property of type FileForm from org.apache.struts -
it was a crazy idea to me to put a Form into a Form first ;-)
3. erhm, and don�t open input stream on blank filename
Ciao J�rg
-----Original Message-----
From: Joey Ebright [mailto:[EMAIL PROTECTED]]
Sent: Sonntag, 09. Februar 2003 22:20
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: RE: Problem with empty file upload field
I too have the same problem - whenever the user does not supply a file
to upload I get an exception. I have tried the 1.1-b3 release of struts
and the 1.6 release of the commons and recieve the same error from
BeanUtils.populate - IllegalArgumentException...
Have you made any progress on this front?
-Joey
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

