3

Is there an equivalent to this statement in jQuery?

var value = document.getElementById(id).files[0];

Using the standard jQuery selectors with .files[0] appended doesn't appear to work, and I can't find an equivalent jQuery command to .files. Any suggestions?

I'm using this to retrieve the file from an input type='file' form element.

bento
  • 4,846
  • 8
  • 41
  • 59
  • I am afraid there isn't for now. Please see [this](http://stackoverflow.com/questions/8436315/jquery-file-attributes) post. – Hausen Zheng Jul 12 '12 at 01:34

1 Answers1

13
$('#id').get(0).files[0]

get(0) return DOM element

James
  • 13,571
  • 6
  • 61
  • 83