I want to read the file path from html input type=file
(the entry selected in the file dialog by the user)
<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>
I want the path of the selected file to be read in my Servlet class
How do I get the file path? Can I read it from var a
?
Or is there any way to directly access the file path from the input type=file
from my servlet?