commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Noel J. Bergman" <>
Subject RE: [PATH]FileUpload fix for filename for msiexplorer
Date Sat, 28 Jun 2003 20:05:31 GMT
> FileUpload should not be in the business of deciding, on behalf of its
> client, how to interpret the content of fields uploaded by the browser.


> > Method getName() in class when used with
> > msiexplorer 5/6 returns a filename with the whole client's
> > filesystem path which creates a problem when you want to save
> > the file on a server's filesystem.

What if I were storing information in a database, and wanted to preserve the
client's fields, or had some other need for the path?

What guarantee is there that the filename, even without the path, is valid
for the server?  What if the client OS uses a different set of allowable
symbols?  What if I already have a file of that name from another user?
What if ... ?  Simply stripping the path from the name isn't going to
address the problem.

Besides which, this functionality is already in

  public class filename {
      public static void main(String[] args) {
          System.out.println(new File(args[0]).getPath());
          System.out.println(new File(args[0]).getParent());
          System.out.println(new File(args[0]).getName());

  $ /usr/local/java/bin/java -cp . filename "~noel/"
  $ /usr/local/java/bin/java -cp . filename "c:/frodo/"
  $ /usr/local/java/bin/java -cp . filename "share:/frodo/"
  $ /usr/local/java/bin/java -cp . filename
  $ /usr/local/java/bin/java -cp . filename

OK, so has some issues with UNC names on linux.  Let's check

  > java -cp . filename "//myserve/share/frodo/"

  > java -cp . filename "\\myserve\share\frodo\"

Works fine.

	--- Noel

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

View raw message