开发者

What are the "allowedTypes" for .rar file (interceptor "fileUpload") in struts2?

<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开发者_C百科-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?


These are the allowed type values -

image/gif,image/jpeg,image/png,image/bmp,application/msword,text/plain,application/pdf,application/ms-excel,application/vnd.ms-excel,image/bitmap

Rar and zip are not one of them.


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.


try <param name="allowedExtensions ">rar</param>

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜