1

I know the files property is read only. but why could not assign this property to another variable? it works in firefox, but not ie.

My code is:

    var element=document.getElementById("fileinput");
    var files=document.getElementById("fileinput").files;
    alert(element);    //here can output HTTPInputElement
    alert(files);      //but here is always undefined in ie;

I do not know why the four line always give me undefined in ie. How can I get the filelist object from input|files as variable in ie?

user504909
  • 9,119
  • 12
  • 60
  • 109

2 Answers2

1

IE9 and below don't have a files property because they only accept one file at a time.

IE: input type="file" multiple

IE10 is supposed to add actual support, I have not tested it yet.

Community
  • 1
  • 1
TheZ
  • 3,663
  • 19
  • 34
  • http://msdn.microsoft.com/en-us/library/ie/hh772931(v=vs.85).aspx In their example they have multiple property. – user504909 Oct 18 '12 at 19:35
  • @user504909 Yes, but it is nevertheless an HTML5 feature and isn't supported until IE10: http://stackoverflow.com/a/10009206/1217408 – TheZ Oct 18 '12 at 19:39
  • The File API is a specification of its own, not part of HTML 5. Support for the multiple attribute is a feature separate to the File API. – Quentin Oct 18 '12 at 19:45
  • @Quentin Then why does the microsoft page that the OP just commented have a section titled "Standards information" with a link to http://www.w3.org/TR/html5/ and have the HTML5 tag? I was just basing my conclusion on that, if it's wrong then so be it. My answer is still correct, though not as informative as yours :O – TheZ Oct 18 '12 at 19:47
  • @TheZ — If you follow the links through, they leave the HTML 5 spec and go to the File API spec. – Quentin Oct 18 '12 at 19:54
  • @Quentin That makes sense, I'll keep that in mind for the future, thanks! – TheZ Oct 18 '12 at 19:55
1

The files property is part of the File API which is still a draft specification and is not supported by IE 9.

Experimental support is in the IE 10 platform preview.

The problem is not that the property cannot be copied, but that it isn't defined in the first place.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335