you can hook the submit event to JS function and then test the content type
before submitting
<head>
 <script language="JavaScript" type="text/javascript">
function doSubmit()
{
  if("%{uploadContentType}%"=="'text/xml'")
  {
  document.form.action="WhateverAction";
  document.form.submit();
  }
}
    </script>
</head>
<s:form action="'javascript:doSubmit()'">
    <s:file
            tooltip="Upload Your XML file"
            label="XML file"
            name="XML file" />
    <s:submit onclick="javascript:doSubmit()" />
</s:form>

----- Original Message -----
From: "Amit Rana" <[EMAIL PROTECTED]>
To: <user@struts.apache.org>
Sent: Wednesday, December 12, 2007 5:48 AM
Subject: Re: Struts 2, file tag, accept attribute not working?


> Hi Anton,
>  Were you able to finally get it to work?
>
>  I am using 2.0.9 and accept just doens't seem to be doing anything.
>
> Regards,
> Amit.
>
> >Re: Struts 2, file tag, accept attribute not working?
> >
> >Anton Pussep
> >Sat, 03 Nov 2007 10:09:23 -0800
> >
> >Modifying FileUploadInterceptor or settings its parameters in struts.xml
> >is not a proper solution since I have two s:file fields in my form and
> >both require different content types. I am not looking for a work
> >around, I rather have the question:
> >
> >Is the accept attribute working at all and if it does, why isn't it
> >working for me?
> >
> >Best,
> >Anton
> >>> ----- Original Message -----
> >>> From: "Anton Pussep" <[EMAIL PROTECTED]>
> >>>
> >>> To: "Struts Users Mailing List" <user@struts.apache.org>
> >>> Sent: Friday, November 02, 2007 6:03 AM
> >>> Subject: Struts 2, file tag, accept attribute not working?
> >>>
> >>>
> >>>> Hello,
> >>>>
> >>>> I am using the following tag for uploading text files:
> >>>>
> >>>> <s:file name="myDoc" accept="text/plain" />
> >>>>
> >>>> I expected it to recognise wrong content types, but it accepts any
> > files
> >>>> I upload. What might be the problem here?
> >>>>
> >>>> I tried this with Struts 2.0.9 and 2.0.11.
> >>>>
> >>>> Best,
> >>>> Anton
>
> ---------------------------------------------------------------------
> 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]

Reply via email to