views:

218

answers:

1
<package name="my-default" extends="struts-default" namespace="/">
<interceptors>
<interceptor-stack name="globalInterceptor">
.....
    <interceptor-ref name="fileUpload">
     <param name="maximumSize">1048576</param>
     <param name="allowedTypes">application/x-rar-compressed</param>
    </interceptor-ref>
.....
</interceptor-stack>
</interceptors>
....
</struts>

I want to mine type for .rar file in struts2 which interceptor "fileUpload", but when I define "allowedTypes" which "application/x-rar-compressed", It doesn't work.

How can I resolve this?

A: 

The MIME type is set by your browser, and this (specially for a .rar file type, not so popular as others) is not fully previsible - I suspect it can vary from browser to browser. If want to play safe, you can omit the allowedTypes option and do the check programatically in your action. Perhaps you'll want also (not as an alternative, but as an complementary check) to check the file extension in the client side, with Javascript.

leonbloy
thank for yr help :)
Tr.Crab

related questions