Reputation: 1287
I've got a really simple problem.
I'm not able to read the file name from the (jsp) file-chooser in servlet. Normally I can get any input data with request.getParameter("name");
Can anybody tell me the shortest way please? this is my code:
<form method="post" enctype="multipart/form-data" action="ImportServlet">
<td> <input type="file" size=20 name="fname"> </td>
<td> <input type="Submit" value="Upload"> </td> </form>
thanks
Upvotes: 0
Views: 1033
Reputation: 34367
MultipartRequest multiPartFile =new MultipartRequest(request,"targetDirectory");
Enumeration files = multiPartFile.getFileNames();
while(files.hasMoreElements() ){
String fileName = (String)files.nextElement();
System.out.println(fileName);
String fileSystemName= multiPartFile.getFilesystemName(fileName );
System.out.println(fileSystemName);
}
Upvotes: 0