input file 文件上传控件隐藏后用button触发它的click事件文件传不上去的解决方案
<HTML>
<HEAD>
<TITLE>upload</TITLE>
<style>
<!--
.addfileA{
position:relative;
cursor:hand;
text-decoration:none;
background-image: url('C:\WINDOWS\Zapotec.bmp');
width:20px;
}
.addfileI {
cursor:hand;
position:relative;
left:0px;
width:20px;
background-color: blue;
opacity:0;
filter:alpha(opacity=0)
}
-->
</style>
</HEAD>
<BODY>
<FORM METHOD=POST ACTION="http://localhost:8080/upload.jsp" enctype="multipart/form-data">
<A hideFocus class=addfileA id=aComposeAttach href="#"> <INPUT hideFocus class=addfileI type=file size=1 name="FF" onchange="this.form.submit()"></A>
<INPUT TYPE="submit" value="提交">
</FORM>
</BODY>
</HTML>
Input type=file 这个控件是不可以用JavaScript触发click事件的,否则是不生效的。我代码其实是让用户看起来点击的是图片,但是实际上点击的是那个透明的Input Type=file