IE输入文件属性未定义

我有以下输入文件标记:

 

在mozilla中,当我运行以下jQuery代码时:

 var input = $('#handlerxhr1')[0]; $('#upload').click(function() { alert(input.files[0]); }); 

我得到回复:[对象文件](这很好)。

但在IE中我得到’input.files.0 is undefined’

我究竟做错了什么? 谢谢。

这看起来不错……

 $(function() { var input = $('#handlerxhr1')[0]; $('#upload').click(function() { alert(input); }); }); 

不确定你是否喜欢这样的事情:

 $(function() { var input = $('#handlerxhr1')[0]; $('#upload').click(function() { var x = $('input[type=file]:eq(0)'); alert(x); }); }); 

IE不支持.files [0]属性,而FF则支持.files [0]属性。 有关详细信息,请参见http://www.w3.org/TR/FileAPI/