I have a form with an input type file.
<form id="upload" action="fileUpload.jsp" method="post">
<input type="file" id="qns" name="qns" accept=".xls,.xlsx"><br><br>
<input type="submit" id="uploadFile" value="Upload File">
</form>
The user should be able to browse to an excel file and on submit, I want the excel data to be uploaded to Oracle XE database(I am using apache POI).
However, in the fileUpload.jsp page, I am unable to access the browsed file since it gives only the file name and not the entire path.
The code in fileUpload.jsp is:
String filename = request.getParameter("qns");
InputStream input = new FileInputStream(filename);
POIFSFileSystem fs = new POIFSFileSystem(input);
Error:
java.io.FileNotFoundException: Abc.xls (The system cannot find the file specified).
Do I need to upload the file to server via servlet and then access it? Please help.