File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes How to get the path of an Uploaded file? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "How to get the path of an Uploaded file?" Watch "How to get the path of an Uploaded file?" New topic
Author

How to get the path of an Uploaded file?

Aashu Mahajan
Ranch Hand

Joined: May 27, 2011
Posts: 114

hi,

i want to know how to get the path of an uploaded file.
I am uploading the file in a JSP Page (using HTML tags and i am not using multipart...) and the request.getParameter() for that file is in another JSP page. How do i get the path of the file uploaded. Please help me

-Ashish Mahajan
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61611
    
  67

You cannot upload a file without using a multipart request. And regardless, you cannot get the original path of the file except under IE which has a security bug that lets you see the path.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Aashu Mahajan
Ranch Hand

Joined: May 27, 2011
Posts: 114

Is there no any alternative way to get the path??
Actually i want to get the path of an image file that is uploaded and want to copy that uploaded image file to a specific folder. so how should i do that when i can't get the full path of an uploaded file?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61611
    
  67

What path are you asking about? The original path on the client or the path of the file after upload on the server? You can't get the former, the latter is wherever your code writes the file.
Miku Ranjan
Ranch Hand

Joined: Oct 11, 2011
Posts: 98
Hi,
Use javascript to set the file path to another hidden input in that form before submit the form.
Aashu Mahajan
Ranch Hand

Joined: May 27, 2011
Posts: 114

ok and can i uplaod, save and retrive image from the server?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to get the path of an Uploaded file?