public void validate(List validationResults) {
    int lastFormError = getRootForm().getLastRequestError();
    if (lastFormError == Form.REQUEST_ERROR_UPLOAD_LIMIT_EXCEEDED) {
      // check if total upload limit is exceeded (e.g. sum of files)
      setErrorKey(i18nErrMaxSize, i18nErrMaxSizeArgs);
      validationResults.add(new ValidationStatusImpl(ValidationStatus.ERROR));
      return;
      // check for a general error
    } else if (lastFormError == Form.REQUEST_ERROR_GENERAL) {
      setErrorKey("file.element.error.general", null);
      validationResults.add(new ValidationStatusImpl(ValidationStatus.ERROR));
      return;
      // check if uploaded at all
    } else if (isMandatory() && (
                    (initialFile == null && (tempUploadFile == null || !tempUploadFile.exists()))
                ||   (initialFile != null && tempUploadFile != null && !tempUploadFile.exists()))  
                  ) {
      setErrorKey(i18nErrMandatory, null);
      validationResults.add(new ValidationStatusImpl(ValidationStatus.ERROR));
      return;
      // check for file size of current file
    } else if (checkForMaxFileSize && tempUploadFile != null && tempUploadFile.exists() && tempUploadFile.length() > maxUploadSizeKB * 1024l) {
      setErrorKey(i18nErrMaxSize, i18nErrMaxSizeArgs);
      validationResults.add(new ValidationStatusImpl(ValidationStatus.ERROR));
      return;
      // check for mime types
    } else if (checkForMimeTypes && tempUploadFile != null && tempUploadFile.exists()) {
      boolean found = false;
      // Fix problem with upload mimetype: if the mimetype differs from the
      // mimetype the webapp helper generates from the file name the match won't work
      String mimeFromWebappHelper = WebappHelper.getMimeType(uploadFilename);
      if (uploadMimeType != null || mimeFromWebappHelper != null) {
        for (String validType : mimeTypes) {
          if (validType.equals(uploadMimeType) || validType.equals(mimeFromWebappHelper)) {
            // exact match: image/jpg
            found = true;
            break;
          } else if (validType.endsWith("/*")) {
            // wildcard match: image/*
            if (uploadMimeType != null && uploadMimeType.startsWith(validType.substring(0, validType.length() - 2))) {
              found = true;
              break;
            } else if (mimeFromWebappHelper != null && mimeFromWebappHelper.startsWith(validType.substring(0, validType.length() - 2))) {
              // fallback to mime type from filename
              found = true;
              break;
            }
          }
        }
      }
      if (!found) {
        setErrorKey(i18nErrMimeType, i18nErrMimeTypeArgs);
        validationResults.add(new ValidationStatusImpl(ValidationStatus.ERROR));
        return;
      }
    }
    // No error, clear errors from previous attempts
    clearError();