Get a list of files attached to an <input> element

I wrap some jQuery functions around a jQuery file upload plugin. It uses the <input type="file" name="files[]" multiple="multiple"> element to make it seem like "connecting" the selected files before downloading. When the form on which the input is posted is submitted, the files are analyzed on the server.

To debug my user interface, I need to see a list of files that are currently โ€œattachedโ€ to the input. Is this possible with Firebug or the Chrome debugger?

+6
source share
2 answers

Yes, you can just use the console and jquery:

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

Then just treat it like an array of files :)

+19
source

Here is how you can check the console:

 $("#idofinput").get(0).files 
+7
source

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


All Articles