简体   繁体   中英

PrimeFaces fileUpload doesn't work on IE<=9

The problem occurs only in IE<=9. Everywhere else fileupload works perfectly.

I'm using PrimeFaces version: 3.4.2. Upgrading to 4.0 doesn't change anything.

I've copied code from: PrimeFaces FileUpload demo

<h:form>

            <p:fileUpload fileUploadListener="#{fileUploadBean.listener}"
                mode="advanced" update="messages" auto="true" sizeLimit="100000"
                allowTypes="/(\.|\/)(gif|jpe?g|png)$/" />

            <p:growl id="messages" showDetail="true" />

        </h:form>

I've even defined:

<meta http-equiv="X-UA-Compatible" content="IE=8" />

On my page it's not working but on FileUpload demo page it's suprisingly working.

I've noticed this strange behaviour on IE <= 9 (Content-Length is 0 and Content-Type is not present - why?):

我的页面请求

But on PrimeFaces page there is (the same browser - IE8/9):

素面要求

I've also tried to set enctype to multipart/form-data and (like on PrimeFaces demo page) application/x-www-form-urlencoded (which is default)

What can I do to get this to work?

You could try to experiment with the primefaces.UPLOADER param if you haven't yet. I had to use

<context-param>
    <param-name>primefaces.UPLOADER</param-name>
    <param-value>commons</param-value>
</context-param>

to make it work on IE8. Maybe that helps for you, too

I've just resolved it.

The reason why it didn't work was that in the layout - XHTML masterpage there were included jquery and jquery.fileupload... but why IE<=9 didn't handle that I don't know (no errors/warnings in the console).

I just modified it to that below:

<o:conditionalComment if="gt IE 9">
    <script src="#{request.contextPath}/js/jquery.min.js"></script>
    <script src="#{request.contextPath}/js/jquery-ui.min.js"></script>
    <script src="#{request.contextPath}/js/jquery.fileupload.js"></script>
</o:conditionalComment>

Now it works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM