当其隐藏用于样式目的时,IE不能发送文件上传 [英] IE can't send file upload when its hidden for styling purposes

查看:116
本文介绍了当其隐藏用于样式目的时,IE不能发送文件上传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



经过一些尝试后,我终于(想)我是一个非常困难的,所以我打开另一个关于样式文件fileupload表单元素的问题。有它的工作,但如往常一样,IE将再次开始抗议。事情是,我将有下面的形式,它隐藏了真正的文件输入与CSS,所以它用一个假的,使用fileHiddenInput div取代它。



html:

 < form enctype =multipart / form-datamethod =post name =uploadformaction => 
< div class =input-append>
< input type =textid =attachedInputButtonsclass =span2name =fileuploadtext>< input type =buttonid =upbuttonclass =btnvalue =选择>< input type =submitname =uploadvalue =uploadenclass =btn>
< / div>
**< div class =fileHiddenInput>< input id =upfiletype =filename =filevalue =upload/>< / div> **
< / form>

css:

  / **文件输入** / 
.fileHiddenInput {
height:0px;
width:0px;
overflow:hidden;
}

我将使用一些jquery发送表单,我可以放置该代码也在这里。但经过多次试验和错误,我会发现,IE9将不会发送文件输入,只要保持隐藏文件输入与CSS使用fileHiddenInput股利。当我让文件输入可见通过删除fileHiddenInput div或使其可见的CSS,然后表单只是发送,因为它应该这样做。



任何人都知道或没有人找到解决方法?

解决方案

隐藏你的一些策略可能会尝试,通过设置样式来关闭屏幕,如

  position:absolute; z-index:19999;顶部:-1000px;左:-1000px; 

另一种方法是使用不透明的控件覆盖文件输入元素。 b

Well, i am pretty stuck so i am opening another question about styling the file-fileupload form element.

After some tryings i'll finally (thought) i had it working, but then as usual IE will start protesting ones again. The thing is, i'll have the following form, it hides the real file-input with css and so it replaces it with a fake one, using the fileHiddenInput div.

html:

<form enctype="multipart/form-data" method="post" name="uploadform" action = "">                    
  <div class="input-append">
    <input type="text" id = "appendedInputButtons" class="span2" name="fileuploadtext"><input type="button" id="upbutton" class="btn" value="Select"><input type="submit" name="upload" value="uploaden" class="btn">
  </div>
  **<div class="fileHiddenInput"><input id="upfile" type="file" name="file" value="upload" /></div>**
</form>

css:

/** file input **/
.fileHiddenInput {
    height: 0px;
    width: 0px; 
    overflow:hidden;
}

I'll use some jquery to send the form, i could place that code also here. But after many trial and error, i'll found out that IE9 won't send the file-input as long if keep hiding the file-input with css using the fileHiddenInput div. When make i'll make the file-input visible by removing the fileHiddenInput div or making it visible using css, then the form just get send as it should do.

Does anyone know or does anyone has found a workaround?

解决方案

A few strategy of hiding you may try, one is by putting the element off the screena by setting style like

position: absolute; z-index: 19999; top: -1000px; left: -1000px;

Another way would be covering the file input element with an opaque control.

这篇关于当其隐藏用于样式目的时,IE不能发送文件上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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