Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Browse file and get path on another page

 
khamhielle gabriel
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 42
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64843
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You cannot get the path to the file -- it is not included for security purposes. Older versions of IE mistakenly included this info.
 
Manjesh Patil
Ranch Hand
Posts: 42
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic