在<input type="file">标签中写上readonly的时候,浏览按钮将是无效的。为了实现前面文本框不可手动更改(降低因用户操作而出现的错误),但是后面的button有效,可以采用以下方法:
<form name="upload">
<input type="file" name="filepath" style="display:none" onChange="document.upload.showpath.value=this.value">
<input name="showpath" readonly>
<input type="button" onClick="document.upload.filepath.click();" value="选择">
</form>