我需要更改"浏览"根据 JSP 中的区域设置按钮文本。 (例如俄语,葡萄牙语)参加 Spring 项目。
以下是浏览按钮的当前实现
<td><input type="file" id="file" name="fileName"/></td>
据我所知,我们无法更改输入类型文件的文字。它是浏览器中浏览按钮的默认行为。
我尝试了以下解决方案
<input type="button" id="button" value="Browse"/>
<input type="file" id="fileName" style="opacity:0; position:relative; left:-40px;" onchange="javascript: document.getElementById ('fileName').value = this.value"/>
但是上面的一个是在浏览器中给出安全问题。
在https://stackoverflow.com/中,它有理想的解决方案(使用输入类型文件更改浏览按钮的文字):
<input type="file" name="filename" id="filename-input" value="browse" size="18" style="float: right; width: 250px;">
任何人都可以帮我解决此问题或实现上述解决方案的方式(https://stackoverflow.com/文件上传)。
答案 0 :(得分:0)
您可能正在寻找类似问题的this answer。
建议使用Bootstrap File-system css样式。
答案 1 :(得分:0)
建议你这样做以保持简单:
<input type="file" style="display:none"/>
<button id="browse">whatever</button>
$('#browse').click(function(){
$('input[type="file"]').trigger('click');
});