IE input file attribute is undefined

ShaneKm picture ShaneKm · Feb 15, 2011 · Viewed 25.9k times · Source

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 response: [object File] (which is good).

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

What am I doing wrong?

Answer

Lalit picture Lalit · Aug 29, 2011

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