0

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

4

2 回答 2

1

用这个

request.getParameter("fname")
于 2012-12-27T06:43:37.720 回答
0
  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);
    }
于 2012-12-26T18:55:58.977 回答