为什么我的表单不能在Internet Explorer 9中上传文件? [英] Why does my form not upload files in Internet Explorer 9?

查看:99
本文介绍了为什么我的表单不能在Internet Explorer 9中上传文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

欢迎使用



我看到很多报告,IE9做一个糟糕的工作上传文件。显然,它有很多的告诫,什么时候会或不会工作(如果有人有一个确定的名单,我很愿意看到它)。但是,我看到的大多数问题/解决方案都与javascript相关,通常是jQuery表单插件或类似的东西。



我的表单不是通过AJAX提交的,文件输入字段不会被css隐藏或隐藏。但是,我每天从IE9的用户试图提交表单和没有什么发生(=表单提交,没有错误,但没有上传文件)的用户几张支持票据我没有得到一个投诉与不同的浏览器和IE8甚至似乎工作(以及它曾经做过的)。



这是我的窗体的顶部。我错过了什么?

 < form action =http://mysite.dev/account-settings/?open= resumemethod =postclass =wpjb-formenctype =multipart / form-data> 

< input type =hiddenname =resume_formvalue =resume_form/>
< fieldset class =wpjb-fieldset-default>

< input id =firstnamename =firstnametype =hiddenclass =regular-textvalue =John/>
< input id =lastnamename =lastnametype =hiddenclass =regular-textvalue =Henry/>
< input id =emailname =emailtype =hiddenclass =regular-textvalue =john.henry@johnhenry.com/>

< div class =wpjb-element-input-checkbox wpjb-element-name-is_active>
< label class =wpjb-label>显示简历? < / label>
< div class =wpjb-field>
< label for =is_active_1>< input type =checkboxclass =name =is_activeid =is_active_1value =1checked =checked/&是< small style =display:inline;>(取消选中以隐藏您的简历)< / small>< / label&

< / div>
< / div>
< div class =wpjb-element-input-select-one wpjb-element-name-file>
< label class =wpjb-label>上传< i>新< / i>恢复文件< / label>
< div class =wpjb-field>
< input style =line-height:1em; id =filename =filetype =fileclass =regular-text/>
< small class =wpjb-hint>接受的文件类型:doc,docx,odf,pdf,rtf< / small>
< / div>
< / div>
< / fieldset>
...

>< fieldset> 的结尾如下:

  .... 
< p class =submit>
< input type =submitname =Submitid =wpjb_submitvalue =保存更改/>
< / p>
< / form>

更新
遇到这个问题,但它不只是我:
http://answers.microsoft.com/en-us/ie/forum/ie9-windows_vista/cannot-upload-files-using-internet-explorer-9 / 5724d921-ae71-e011-8dfc-68b599b31bf5



Update2
我看到了很多建议添加元标记以强制用户代理到IE8 ...
< meta http-equiv =X-UA-Compatiblecontent =IE = 8/> code>
我不想这样做,因为虽然我支持IE8,我的网站上的许多元素在IE8与IE9中呈现不同。这将创建一个相当粗糙的用户体验,因为任何IE用户会遇到我临时时间扭曲回到特定页面上的IE8。

解决方案

  $('

#complete_profile input [type =submit]')。click(function(){
setTimeout(function(){
$('#complete_profile form')。submit();
},0);
});

当表格提交时,可能会导致重复提交。

Welcome to episode 32,342,343 of "Why does Internet Explorer Suck So Much?"...

I've seen lots of reports that IE9 does a crappy job uploading files. Apparently it has lots of caveats about when it will or won't work (If someone has a definitive list I'd love to see it). However, most of the problems/solutions I see have found are related to javascript, usually the jQuery form plugin or something similar.

My form is not submitted via AJAX and the the file input field is not hidden or obscured with css. Yet, I get several support tickets per day from users on IE9 trying to submit the form and "nothing happens" (=the form submits. No errors, but the file is not uploaded.) I haven't gotten a single complaint with a different browser, and IE8 even seems to work (as well as it ever does).

Here's the top of my form. Am I missing something?

<form action="http://mysite.dev/account-settings/?open=resume" method="post" class="wpjb-form" enctype="multipart/form-data">    

        <input type="hidden" name="resume_form" value="resume_form" />
        <fieldset class="wpjb-fieldset-default">

            <input id="firstname" name="firstname" type="hidden" class="regular-text " value="John" />
            <input id="lastname" name="lastname" type="hidden" class="regular-text " value="Henry" />
            <input id="email" name="email" type="hidden" class="regular-text " value="john.henry@johnhenry.com" />

            <div class="wpjb-element-input-checkbox wpjb-element-name-is_active">
                <label class="wpjb-label">Show resume? </label>
                <div class="wpjb-field">
                    <label for="is_active_1"><input type="checkbox" class="" name="is_active" id="is_active_1" value="1" checked="checked" /> Yes <small style="display:inline;">(Uncheck to hide your resume)</small></label>

                </div>
            </div>
            <div class="wpjb-element-input-select-one wpjb-element-name-file">
                            <label class="wpjb-label">Upload a <i>new</i> resume file</label>
                <div class="wpjb-field">
                    <input style="line-height:1em;" id="file" name="file" type="file" class="regular-text " />
                    <small class="wpjb-hint">Accepted file types: doc, docx, odf, pdf, rtf</small>
                </div>
            </div>
        </fieldset>
        ...

It goes on like this with a couple more <fieldset>s then ends like this:

    ....
    <p class="submit">
        <input type="submit" name="Submit" id="wpjb_submit" value="Save Changes" />
    </p>
</form>

Update I'm happy for everyone who has never experienced this problem but it's not just me: http://answers.microsoft.com/en-us/ie/forum/ie9-windows_vista/cannot-upload-files-using-internet-explorer-9/5724d921-ae71-e011-8dfc-68b599b31bf5

Update2 I'm seeing a lot of suggestions to add a meta tag to force the user agent to IE8... <meta http-equiv="X-UA-Compatible" content="IE=8" /> I don't want to do this because although I do support IE8, many of the elements on my site render differently in IE8 vs. IE9. This would create a rather sloppy user experience as any IE users would experience I temporary "time warp" back to IE8 on that specific page.

解决方案

I was able to fix this nightmare of a problem by wrapping a jQuery form submit in a setTimeout:

$('#complete_profile input[type="submit"]').click(function(){
  setTimeout(function() {
    $('#complete_profile form').submit();
  }, 0);
});

This may cause duplicate submission when the form DOES submit, however, so be careful.

这篇关于为什么我的表单不能在Internet Explorer 9中上传文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆