How to get full path using <input id="file" name="file" type="file" size="60" > in jsp [duplicate]
Possible Duplicate:
How to get the file path from HTML input form in Firefox 3
<input id="file" name="file" type="file" size="60" >
<input type="Submit" value="Generate XML" >
I don't want to upload that file!! I need to pass the browsed file from The JSP file to the servlet.
Copy and the paste these two input fields.
<input type="file" name="upload" id="upload" />
<input type="text" name="fileName" id="fileName" value="" />
Below the fields paste this jquery. NOTE: Not forget to include the jquery file.
$("#upload").change(function () {
var filename = $(this).val();
$('#fileName').val(filename);
}).change();
Add a hidden input
field and save the file name on that field and remove the file from the file input
via Javascript.
for example.
HTML
<input type="hidden" value="" name="hd1" id="hdFile"/>
<input id="file" name="file" type="file" size="60" />
<input type="Submit" value="Generate XML" />
JavaScript
var filePath = document.getElementById('file').value;
document.getElementById('hdFile').value = filePath;
document.getElementById('file').value = '';
精彩评论