praba
praba

Reputation: 1084

accept attribute is not working in <s:file> tag of struts2

I am trying to validate the content types of uploading files using accept attribute but it seem to be not working. Here is my code.

<s:file theme="simple" name="fileUpload" accept="image/jpeg"/>

i also tried

<s:file theme="simple" name="fileUpload" accept="image/*"/>

Both are not working what could be the problem?

Upvotes: 1

Views: 1166

Answers (1)

Aleksandr M
Aleksandr M

Reputation: 24396

The HTML accept attribute is not supported in IE and Safari. You can define allowed mime types in struts.xml for you file upload action like that:

<action name="..." class="...">
  <interceptor-ref name="defaultStack">
     <param name="fileUpload.allowedTypes">image/jpeg</param>
  </interceptor-ref>
  <result>...</result>
</action>

See others parameters you can configure in fileUpload interceptor.

Upvotes: 2

Related Questions