| 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: 38
|
|
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: 56529
|
|
|
You cannot get the path to the file -- it is not included for security purposes. Older versions of IE mistakenly included this info.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Manjesh Patil
Ranch Hand
Joined: Sep 24, 2010
Posts: 38
|
|
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
|
|
|