我有文件字段在页面demo.jsp中上传文件(pdf),现在我想当用户要编辑此页面时说demo.jsp,之前上传的文件名将填入文件字段而不是“选择文件” ”
答案 0 :(得分:0)
您可以尝试这样的事情(解决)
<input type="text" id="fileName" readonly="readonly" >
</br>
<small>Here change this with whatever dynamically</small>
</br>
<div class="file_input_div" style="display: inline;">
<input type="button" id="button" value="Open"/>
<input type="file" style="opacity:0; position:relative; left:-40px;" onchange="javascript: document.getElementById ('fileName').value = this.value"/>
</div>
修改2
<small id='fileName'>Here change this with whatever dynamically</small>
</br>
<div class="file_input_div" style="display: inline;">
<input type="button" id="button" value="Open"/>
<input type="file" style="opacity:0; position:relative; left:-40px;" onchange="javascript: document.getElementById('fileName').innerHTML = this.value"/>
</div>