Reputation: 4084
Hi I need to get the name of the file the user selects from the input type file control and display it on to the page. The jquery onchange event does not work in ie 8. Can anybody tell me the solution?
// this is my jquery code
$(document).ready(function()
{
$('input[type=file]').change(function(){
var val=$('input[type=file]').val();
alert(val);
$("#textfile").attr("value", val);
});
});
//HTML Code
<input type="file" class="file" name="upload_file" id="UserIcon" />
<input type="text" id='textfile' width="100px" />
But in IE After uploading i saw that some thing added after file
input name="upload_file" class="file" id="UserIcon" type="file" jQuery15102237614897631498="27" value="C:\Users\Public\Pictures\Sample Pictures\Tulips.jpg"/>
Upvotes: 0
Views: 7876
Reputation: 8346
This is not a jQuery problem, but a JavaScript problem. As far as I know IE does not know the onchange event handler. Instead of change, try click.
Getting jQuery to recognise .change() in IE
Upvotes: 1