How to get the file name for <input type="file" in jsp
Posted
by deepthinker121
on Stack Overflow
See other posts from Stack Overflow
or by deepthinker121
Published on 2010-04-07T12:34:02Z
Indexed on
2010/04/07
12:53 UTC
Read the original article
Hit count: 337
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?
© Stack Overflow or respective owner