In mozilla, when I run the fol...">

IE input file identifier undefined

I have the following input file tag:

<input type="file" id="handlerxhr1" /> 

In mozilla, when I run the following jQuery code:

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

I get the answer: [object File] (which is good).

But in IE, I get 'input.files.0 is undefined'

What am I doing wrong? Thanks.

+4
source share
2 answers

That seems good enough ...

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

Not sure if you had something like this:

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

IE does not support the .files [0] property, whereas FF does. See http://www.w3.org/TR/FileAPI/ for more details.

+6
source

Source: https://habr.com/ru/post/911432/


All Articles