我想从html读取文件路径input type="file"
(用户在文件对话框中选择的条目)
<script>
function OpenFileDialog(form) {
var a = document.getElementById("inputfile").click();
SampleForm.filePath.value = //set the path here
document.SampleForm.submit();
}
</script>
<form name="SampleForm" action="TestServlet" method="get">
<input type="file" style="display:none;" id="inputfile"/>
<a href="javascript:OpenFileDialog(this.form);">Open here</a>
<input type="hidden" name="filePath" value=""/>
</form>
Run Code Online (Sandbox Code Playgroud)
我希望在我的Servlet类中读取所选文件的路径如何获取文件路径?我能从中读出来var a吗?或者有没有办法input type="file"从我的servlet 直接访问文件路径?