0

I am writing a Web Project with Java. I have the problems with reading files on client machine's local disk using Servlet. When I directly run the following code in Eclipse, it runs well. I can read the files on other client machine (Not on server machine). But, when I make the project war file, put it on the Tomcat Server and run it, I cannot read the files. Thanks for any hints and advice in advance. My code is here:

File file = new File("\\\\dell-nb\\SharedFile");
  File[] list=file.listFiles();
  for(int i=0;i<list.length;i++)        
    System.out.println(list[i].getName());
Phyo Gyi
  • 11
  • 4

1 Answers1

0

It is as 'designed', at best for security reasons. Imagine that any server can access any files in your computer. You will not have any privacy. The best way to transfert file from client to server is with an upload. Search on the net on how to make an upload page in java.

Check this: http://commons.apache.org/proper/commons-fileupload/ and How to upload files to server using JSP/Servlet?

Community
  • 1
  • 1
JFPicard
  • 5,029
  • 3
  • 19
  • 43