<label for="TEST">上传文件</label>
<form action="#" style="background-color: gray">
<div style="width:0px;height:0px;overflow: hidden">
<input type="file" id="TEST" style=""/>
</div>
</form>
兼容IE7+,Chrome,Firefox
注意IE7 IE8下 input[type=file]所在元素必须可见的,也就是说,这个 input[type=file]及其父辈元素必须可见,但是可以通过设置width:0px;height:0px;overflow:hidden达到视觉看不到的效果。
然后通过对label标签做样式修改,即可生成美观的上传按钮,此部分就不说了。