0
我有文件字段上传页面demo.jsp中的文件(pdf),现在我想当用户要编辑此页面说demo.jsp,以前上传的文件名将在“选择文件”位置填充文件字段。更改通过文件名在jsp文件域中选择文件的文本
我有文件字段上传页面demo.jsp中的文件(pdf),现在我想当用户要编辑此页面说demo.jsp,以前上传的文件名将在“选择文件”位置填充文件字段。更改通过文件名在jsp文件域中选择文件的文本
你可以尝试这样的事情(变通)
<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>
其实我希望我上传的文件名显示在文件字段中,以便如果用户在编辑其他字段时不选择新文件并且不改变文件字段,则不应该要求文件字段(选择文件),并且旧的填充文件名是在表中更新。 – RJ007
@ user2821027检查我的更新答案 –