• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

servlet upload file with full path

 
Kee Kee moon
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65218
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Nam Ha Minh
Ranch Hand
Posts: 504
Eclipse IDE Firefox Browser Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Stefan Evans
Bartender
Posts: 1784
10
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18302
56
Android Eclipse IDE Linux
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic