使用“隐藏”iframe上传文件在资源管理器中不起作用

时间:2013-01-08 14:52:24

标签: javascript jquery internet-explorer iframe

我有这个表格html:

<form id="testForm" method="post" action="upload.php" target="upload_target" enctype="multipart/form-data" style="margin-bottom:0;">
    <textarea name="infoText"></textarea>
    <input id="file-input" name="bid-file" type="file" style="visibility:hidden;">
    <input type="submit" id="submitBtnFile" style="visibility:hidden;">
</form>
<button id="#submitBtn">Submit</button>

<iframe id="upload_target" name="upload_target" src="#" style="width:0;height:0;border:0px solid #fff;"></iframe>

我的js是:

$('#submitBid').click( function(){
    $('#objectCommentsSubmit').trigger('click');
    $('#submitBtnFile').trigger('click');
    $('.loading-bid').show();
});

这适用于Safari,Firefox和Chrome,但不适用于IE!

有人能告诉我IE的错误吗?

谢谢!

1 个答案:

答案 0 :(得分:1)

尝试更改

$('#submitBtnFile').trigger('click');

$("#testForm").submit();