我使用了以下方法
HTML
<input type="file" id="loadfile" />
Run Code Online (Sandbox Code Playgroud)
JavaScript的
var file = document.getElementById('loadfile').files[0];
alert( "name " + file.name + "Size " + file.size );
Run Code Online (Sandbox Code Playgroud)
它除了IE之外还可以正常工作:(如何进入IE?
我有以下输入文件标记:
<input type="file" id="handlerxhr1" />
Run Code Online (Sandbox Code Playgroud)
在mozilla中,当我运行以下jQuery代码时:
var input = $('#handlerxhr1')[0];
$('#upload').click(function() {
alert(input.files[0]);
});
Run Code Online (Sandbox Code Playgroud)
我得到回复:[对象文件](这很好).
但是在IE中我得到'input.files.0 is undefined'
我究竟做错了什么?谢谢.