File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Get a full path from a file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Get a full path from a file" Watch "Get a full path from a file" New topic

Get a full path from a file

Hernan Tavella
Ranch Hand

Joined: Apr 28, 2012
Posts: 42
Hello, how can i get the absolute path from an FileItem (org.apache.commons.fileupload Interface FileItem) i try several way but i can't get it.

This an example of what i need to do.

the c:\\pruebas\\ i should get it with some method or something.

Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

I don't understand what "absolute path" you are asking about. From the code you posted, it looks like you wanted an absolute path on the server. But a FileItem object doesn't correspond to any location in the server's file system, it's just a set of bytes which was uploaded from the client system.

There's nothing stopping you from choosing a directory on the server to store the uploaded file in, and in fact that would probably be the best approach.
I agree. Here's the link:
subject: Get a full path from a file
It's not a secret anymore!