Below is what I have in jsf 2.0
<tr>
<th width="19%" align="left"><h:outputLabel value="Photo" /></th>
<th width="2%">:</th>
<td width="19%"><h:inputText value="#{PersonalInformationDataBean.photo}" size="80" id="photo" readonly="true"/>
<input type="file" name="pathPhoto" onchange="alert('you changed me...'+window.document.patentForm.pathPhoto.value);window.document.patentForm.photo.value=window.document.patentForm.pathPhoto.value"/></td>
</tr>
When I click on button Choose File
and select some file, I get different path.
Chrome & Safari
I get path name as C:\fakepath\jobs_dubizzle.rtf
. I always get output as C:\fakepath\FileName
irrespective of any location.
Mozilla Firefox
It gives me full path perfectly.
Any idea why I am getting like this? (Different behavior across browsers.) And how to overcome? I need full path of that file so that I can use same path for storing the path in MySQL data.
Update 1
What I wanted to do is when I submit the form, I want that file to get uploaded in mysql data. Right now I would be selecting images. To upload images, I would be using code as provided here.
As you see, I would be needing full path for statement below.
File image = new File("C:/image.jpg");
That is why, I was curious to get full path of the selected file.
Any idea to get this?