方法1:label与for进行绑定实现文字点击选择按钮功能
<style>
label{
cursor:pointer;
}
.fileSpan{
cursor:pointer;
margin-left:22pt;
}
.fileSpan input {
display:none;
}
.fileSpan .button {
background: #0C8CC4;
color: #fff;
font-size: 12px;
margin-right: 5px;
padding: 7px 20px;
}
</style>
<span class="fileSpan">
<label for="photo"><span class="button">CHOOSE A FILE</span></label>
<input type="file" name="photo" id="photo" />
</span>
方法2:通过JS实现
<div>
<input type="file" style="display:none" οnchange="Upload()" id="FileUpload"/><input type="button" value="FileUpload" οnclick=" OpenFile()" class="btn btn-info"/>
</div>
<script>
function OpenFile() {
document.getElementById('FileUpload').click();
}
</script>