This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes servlet upload file with full path Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "servlet upload file with full path" Watch "servlet upload file with full path" New topic
Author

servlet upload file with full path

Kee Kee moon
Ranch Hand

Joined: Dec 11, 2009
Posts: 147
I use Servlet for uploading file, but I need full path + file name.
Please shed a light.

Thank you for your help.



Thank you very much for all of your help. I have decided to use other method instead of using full path as param.
And, I am sorry for the trouble.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

No, you don't. It's none of your business where the file was uploaded from.

However if you think it is, then go ahead and explain why.
Kee Kee moon
Ranch Hand

Joined: Dec 11, 2009
Posts: 147
Paul Clapham wrote:No, you don't. It's none of your business where the file was uploaded from.

However if you think it is, then go ahead and explain why.



I need the upload full path, so I can pass into a function which requires full path string.

Thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

That's not an answer. "You need it because you need it" doesn't tell use why you really need it. I any case, except for buggy versions of IE, you can't get it, so you'll need to make other plans.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Nam Ha Minh
Ranch Hand

Joined: Oct 31, 2011
Posts: 498

Kee Kee moon wrote:

I need the upload full path, so I can pass into a function which requires full path string.



It is possible for the full path on sever. Otherwise, as Paul set, you cannot get it from client side, for security reason I think.


PM Me If You Want to get Urgent Help on Java Programming
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1016
So if you're doing it properly, what your servlet gets made available to it is the name of the file, and its contents as an input stream.
Helper libraries such as the commons file upload can be useful in dealing with uploading files

So if you want to read the file, read it from the InputStream available.

The main reason people want to get the full file path is so that they can open a FileInputStream on the server, to the file which is sitting on the client. This will work if (and only if) the server and the client are one and the same machine (fairly standard for developing) but for obvious reasons, will not as soon as you deploy it elsewhere.

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15963
    
  19

Internet Explorer includes the client-side full filesystem pathname as part of the file upload metadata. I actually consider this to be a security problem because it gives someone else detailed information about my computer's filesystem organization without my ability to control it.

Most other web clients do not send the full client filesystem path.

In either event, the choice of what to send is not determined by the server, it is determined by the client. And if the client chooses full-path, local-path, or randomly-made-up garbage (including hackers attempting to open up exploits), there's not a single thing the server can do about it.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: servlet upload file with full path
 
Similar Threads
contextpath,servlet path and full path
Log file not being created or appended to with log4j
Correct answer
How to get servlet's full path name
Problem in Tomcat