commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Cooper <>
Subject Re: Check file path really exists
Date Thu, 21 Oct 2004 04:42:38 GMT
On Mon, 18 Oct 2004 19:22:07 -0700 (PDT), Joe Smith <> wrote:
> My uses apache commons upload. And I use the following to check if the path
really exists. The program runs in UNIX, and when user selects a file from windows machine,
it seems always not found the path. But if I test it in local machine, it is working, any
ideas?? Please advise. Thanks!!

You don't provide any information on where the value of 'fileNamePath'
came from, so it's a little difficult to tell...

However, if you are using the value of FileItem.getName() for this,
that is almost certainly your problem. The 'name' property is provided
by the client (usually a browser), and may be a base file name or a
full path to a file, depending on that client. If it's a full path,
then it will be OS dependent.

In general, it's a bad idea to try to use the name of the original
file as the name of the uploaded file. Apart from the path issues
mentioned above, there are also the obvious issues of multiple uploads
of the same file, possibly by different people, leading to all sorts
of potential conflicts.

Martin Cooper

> File files = new File(fileNamePath);
> if (!files.exists())
> { uploadFileExists = false;
> break;
> }
> ---------------------------------
> Do you Yahoo!?
> - Register online to vote today!

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message