I have an application that upload images file from my local harddrive to the server. Before the upload, it checks whether the file existing on the local drive. And I use file.exists() to do this. When the application was running on my pc, it worked fine. But when the application was deployed and run on the server, this file.exists() always returned false even thought I could see the file on the C: drive. I am wondering is it because I can't use this file.exists() to check local files from server? If it is, anybody has any solutions to this problem?
File.exists(), like all of File's methods, operates only on files on the machine the code is running on. There's no way for code on the server to ask whether a file exists on a client machine. You'd have to have some code running on the client (an applet, a Java Webstart application, etc) to do that.
But as far as uploading a file goes, you have to be doing one of two things: using HTTP file upload, in which case the user has to pick the file in a file browser; or you already have some code on the client. If the user is picking the file, then of course it exists on the desktop.