aspose file tools
The moose likes Java in General and the fly likes Can I user file.exists() from server to check local file? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Can I user file.exists() from server to check local file?" Watch "Can I user file.exists() from server to check local file?" New topic
Author

Can I user file.exists() from server to check local file?

Teresa Lee
Greenhorn

Joined: Feb 01, 2008
Posts: 24
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?

Thanks.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24057
    
  13

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.


[Jess in Action][AskingGoodQuestions]
Teresa Lee
Greenhorn

Joined: Feb 01, 2008
Posts: 24
I see. Thank you very much.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can I user file.exists() from server to check local file?
 
Similar Threads
Install a file from server to local machine
Uploading File??
How to determine if 2 files exists
ftp
How to select the destination at run time while uploading a file.