aspose file tools*
The moose likes Servlets and the fly likes Browse file and get path on another page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Browse file and get path on another page" Watch "Browse file and get path on another page" New topic
Author

Browse file and get path on another page

khamhielle gabriel
Greenhorn

Joined: Aug 15, 2011
Posts: 19
Hi,

can anyone help me , i was wondering how can i be able to get the path ohf the selected file from apage using the input type="file"

and the be abe to use the path in another page.

request.getparameter is obvioudly not the answer but i run out of altelnatives.. do you know how can i do that?


thank you in advance God bless.
Prakash Mani - Attur
Ranch Hand

Joined: Oct 08, 2009
Posts: 100
What we do in our project is, we load the file from the client system and keep it server and we refer the server in further pages..
Manjesh Patil
Ranch Hand

Joined: Sep 24, 2010
Posts: 40

Hi
you must use "ENCTYPE='multipart/form-data' attribute on your Form element.

example

<FORM ENCTYPE='multipart/form-data'
method='POST' action='/myservlet'>
<INPUT TYPE='file' NAME='mptest'>
<INPUT TYPE='submit' VALUE='upload'>
</FORM>

then in the servlet or JSP ..request.getParameter("mptest") would give you the file path being uploaded. then you can use request.setAttribute or session.setAttribute based on the scope to carry the path value to different resources.


Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

You cannot get the path to the file -- it is not included for security purposes. Older versions of IE mistakenly included this info.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Manjesh Patil
Ranch Hand

Joined: Sep 24, 2010
Posts: 40

khamhielle,
oh correct request.getParameter() doesnot work in newer browsers as Bear Bibeault said.You have to parse request.getInputStream or you can make use of one of apache commons fileUpload utils or com.oreilly.servlet.MultipartRequest APIS

-Manjesh
 
 
subject: Browse file and get path on another page
 
Similar Threads
put filestreams to file
JSP Current Path
Basic help
Uploading and Downloading files
How to get the path of an Uploaded file?