Hi Doug, 

I don't know if you've already found solution to your problem but what you can do is 
to put a form validation in your ActionForm that handles that, here is what I did for 
mine (it also handles the case if a file is empty, saying with a 0 Kb size) :

    /**
     * Validate the properties that have been set from this HTTP upload request,
     * and return an <code>ActionErrors</code> object that encapsulates a
     * validation error relative to a missing file to be uploaded.  
     * If no errors are found, return 
     * <code>null</code> or an <code>ActionErrors</code> object with no
     * recorded error messages.<br>
     *
     * Creation date: (13.11.01 19:19:10)
     *
     * @param mapping The mapping used to select this instance
     * @param request The servlet request we are processing
     *
     * @return ActionErrors
     */
 public ActionErrors validate(ActionMapping mapping, HttpServletRequest request)
 {
     ActionErrors errors = new ActionErrors();
     FormFile theFile = this.getThefile();   

     if (theFile == null || theFile.getFileName().length() == 0) // as Struts always 
do a temp file for each file you want to upload, "theFile==null" is always false
         errors.add("upload", new ActionError("uploadForm.error.uploadfile.required"));

     if (theFile.getFileSize() == 0)
         errors.add("uploadsize", new 
ActionError("uploadForm.error.filesize.zero.notallowed"));

     return errors;
 }

Hope it helps, 

Daniel

Reply via email to