how to get value path file from jsp form- input type file
hello , i have problem which i need to get path file if i select from my pc. from my code the value that i could get just name of the file not full path of the file. here is my code.
i hope could somebody help me to pass the value input type file from form1.jsp file to attach.jsp file.
form1.jsp
Code :
<FORM name="FileForm" ACTION="attach.jsp" METHOD=POST >
<br><br><br><center>
<table border="0" bgcolor=#ccFDDEE><tr>
<td colspan="2" align="center"><B>UPLOAD THE FILE</B>
</td>
</tr>
<tr>
<td colspan="2" align="center"> </td>
</tr>
<tr>
<td><b>Choose the file To Upload:</b></td>
<td>
<INPUT NAME="file1" TYPE="file" >
</td></tr>
<tr><td colspan="2" align="center">
<input type="submit" value="Send File"> </td>
</tr>
<tr>
</tr>
</table>
</center>
</FORM>
attach.jsp
Code :
String filename = request.getParameter("file1");
System.out.println(filename);
System.out.println(request.getParameter("email"));
DataSource source = new FileDataSource(filename);
messageBodyPart.setDataHandler(new DataHandler(source));
messageBodyPart.setFileName(filename);
multipart.addBodyPart(messageBodyPart);
m.setContent(multipart);
// Send the message
//transport.send(m);
System.out.println("Msg Send ....");
Re: how to get value path file from jsp form- input type file
Quote:
Originally Posted by
meeGoreng
hello , i have problem which i need to get path file if i select from my pc. from my code the value that i could get just name of the file not full path of the file.
Unfortunately, we couldn't get absolute path of the file on client. Why? Because it is security restriction in most browsers. My recent test shows that FireFox and Chrome returns only the file name, while IE 6 returns the whole absolute path.
java memory
Re: how to get value path file from jsp form- input type file
Are you sure, you placing the files at the correct directory of your local server (say tomcat or whatever you using)?
Re: how to get value path file from jsp form- input type file
actually i need pass the file that i select from my pc and then sent to my email. it means i cannot upload that file? i need save the file in to server first then server will pass the file to the email?
it is correct ??
Re: how to get value path file from jsp form- input type file
Kindly check the following links.
May be these help you....
1
2
3
4