File upload Primefaces p:fileUpload在IE 10中不起作用

File upload Primefaces p:fileUpload在IE 10中不起作用,file-upload,primefaces,File Upload,Primefaces,p:fileUpload中的Update属性和onComplete在IE10中不起作用。在IE 9中,sizeLimit属性被忽略。有没有人遇到过这种情况 我曾尝试在p:fileUoload上使用onComplete属性调用p:remotecommand,但看起来即使是onComplete在IE10中也不起作用 <h:form id="file" enctype="multipart/form-data"> <p:outputLabel value="Test.

p:fileUpload中的Update属性和onComplete在IE10中不起作用。在IE 9中,sizeLimit属性被忽略。有没有人遇到过这种情况

我曾尝试在p:fileUoload上使用onComplete属性调用p:remotecommand,但看起来即使是onComplete在IE10中也不起作用

<h:form id="file" enctype="multipart/form-data">
        <p:outputLabel value="Test........"></p:outputLabel>
        <p:fileUpload label="Browse..." description="Select PDF file"
            auto="true" sizeLimit="500000"
            oncomplete="refreshData()"
            onstart="alert('test');" mode="advanced"
            fileUploadListener="#{fileUpload.handleFileUpload}"
            allowTypes="/(\.|\/)(pdf|png)$/">

        </p:fileUpload>
        <p:inputText value="#{fileUpload.test}" id="test" />
        <p:remoteCommand name="refreshData" action="#{fileUpload.setData}"
            update="test"></p:remoteCommand>
    </h:form>

终于意识到这是primefaces中的一个bug

固定在:

TargetVersion-4.0
TargetVersion-3.5.9


使用此CSS解决方案。我从修复这个问题的方法中得出这个结论

.fileinput-button input {
    -moz-transform : none !important;
    border : none !important;
    border-width : 0 !important;
    transform : translate(-300px, 0) scale(4) !important;
    font-size : 23px !important;
}
* + html .fileinput-button {
    line-height : none !important;
    padding : 2px 15px !important;
}

这似乎是绝对位置的问题。把它改成固定的。这对我来说是有效的:

.fileupload-buttonbar .ui-button input {
    ...
    position                          : fixed;
    ...
}

这在新的4.0 Primefaces版本中已修复,但是如果您仍然使用旧版本的Primefaces,则可能仍然需要解决方法

我能够在上传文件后使用onstart属性进行更新,该属性在IE10中仍然有效

创建一个隐藏字段,其中包含一个值,该值作为从fileUploadListener调用的方法的一部分进行更新。然后将p:fileUpload的onstart属性设置为如下所示:

function checkUpload() {

    //this should call a p:remoteCommand that refreshes your hidden value
    refreshHiddenValue(); 

    var hiddenFieldValue = $('#hiddenFieldId').val();
    if(hiddenFieldValue) {
        //this should call a p:remoteCommand that refreshes the
        //sections you want refreshed after the upload has finished
        refreshSections();
    }
    else {
        setTimeout(checkUpload, 1000);
    } 
} 

升级到IE10后,我还遇到了p:fileUpload的问题。JavaScript错误开始出现(“XML文档中的语法错误”)

它有助于将X-UA-Compatible标题更改为IE=EmulateIE9


从PF 3迁移PF 5.1后,我不得不面对这个问题,多亏我解决了:

这是生成的html代码:

<div class="ui-fileupload-buttonbar ui-widget-header ui-corner-top">
    <span class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-left ui-fileupload-choose" >
        <span class="ui-button-icon-left ui-icon ui-c ui-icon-plusthick"></span>
        <span class="ui-button-text ui-c">upload</span>
        <input name="upload" type="file">
    </span>
</div>

看起来,即使有了这个修复,来自
p:fileUpload
组件属性的ajax更新在IE 10中也不起作用。我正在调查,但欢迎提出建议。
.ui-fileupload-buttonbar .ui-fileupload-choose input
{
    position:absolute;
    top:0;
    right:0;
    margin:0;
    border:solid transparent;
    border-width:0 0 1px 1px;
    opacity:0;
    filter:alpha(opacity=0);
    -o-transform:translate(250px,  -50px) scale(1);
    direction:ltr;
    cursor:pointer;
    z-index:5000;
    width:100%;
    height: 20px;       
}

.ui-button {
    position: relative;
    overflow: hidden;
}
.ui-button input[type=file] {
    position: absolute;
    top: 0;
    right: 0;
    min-width: 100%;
    min-height: 100%;
    font-size: 100px;
    text-align: right;
    filter: alpha(opacity=0);
    opacity: 0;
    outline: none;
    background: white;
    cursor: inherit;
    display: block;
}