<html>
<title>关于input file 重写</title>
<head>
<style>
.file_div {
color: #154BA0;
border: 1px solid #86B9D6;
background: #D9EEF9;
filter: Alpha(Opacity=0, Style=0);
position: absolute;
opacity: 0.0;
width:200px;
}
.text_div{
position: absolute;
filter: Alpha(Opacity=100, Style=0);
opacity: 1.0;
z-index: -1;
width:200px;
}
</style>
<script>
function setTextByFile(name_code){
document.getElementsByName("text_"+name_code)[0].value = document.getElementsByName("file_"+name_code)[0].value;
}
</script>
</head>
<body>
<table>
<tr>
<td style="height:30px;">
<div class="file_div"><input type="file" size="2" name="file_0000" onchange="setTextByFile('0000')"></input></div>
<div class="text_div"><input type="text" size="3" name="text_0000" ><input type="button" value="上传" style="width:50px;"></div>
</td>
</tr>
<tr>
<td style="height:30px;">
<div class="file_div"><input type="file" size="2" name="file_0001" onchange="setTextByFile('0001')"></input></div>
<div class="text_div"><input type="text" size="3" name="text_0001"><input type="button" value="上传" style="width:50px;"></div>
</td>
</tr>
</table>
</body>
</html>
测试通过 IE8,FF12.0,opera11.64、chrome可行