6

I am wrapping some jQuery functionality around jQuery File Upload plugin. It uses an <input type="file" name="files[]" multiple="multiple"> element to what it seems like "hook up" the selected files before the upload. When a form on which the input resides is submitted, files are parsed on the server.

In order to debug my UI, I need to see the list of files currently "attached" to the input. Is it possible with Firebug or Chrome debugger?

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Maxim V. Pavlov
  • 10,303
  • 17
  • 74
  • 174

2 Answers2

20

Yes, you can just use the console and jquery:

$("#idofinput")[0].files

Then just treat it like an array of files :)

Justin Pihony
  • 66,056
  • 18
  • 147
  • 180
  • @SarathSaleem You seem to be correct. Here is a jsfiddle (not mine) that exhibits this...http://jsfiddle.net/eq3Qv/176/ – Justin Pihony Feb 15 '13 at 17:08
  • Here is a SO where this problem is brought up, but not quite addressed: http://stackoverflow.com/questions/5000950/ie-input-file-problem – Justin Pihony Feb 15 '13 at 17:11
  • Finally, here is another SO that lists some alternatives (mainly that you have to use ActiveX)...no wonder IE sucks...http://stackoverflow.com/questions/13512009/how-to-get-file-size-from-clientside-using-javascript-in-ie – Justin Pihony Feb 15 '13 at 17:15
  • 1
    Correction: $("#idofinput")[0].files 'files' is a property of the element, not the jQuery object. – Doug Domeny Oct 29 '13 at 20:13
  • Can somebody please help me? I'm only able to get a single file using this but I selected multiple files. It's driving me insane! – Mihael Keehl Feb 23 '17 at 15:59
  • @user2081044 you should open up a separate wuestion – Justin Pihony Mar 04 '17 at 06:33
  • Never mind, I fixed it. I just created a separate array because all the files in the input get overwritten once the user makes a different selection of images. It was a little tedious, but the user had to be able to add/delete images from a central point so I convert them to base64 and store them in a separate array and it works :) – Mihael Keehl Mar 04 '17 at 14:58
7

This is how you can check in console:

$("#idofinput").get(0).files
Wouter J
  • 41,455
  • 15
  • 107
  • 112
romelmederos
  • 198
  • 3
  • 5