Getting the file names of a multiple input form field with jQuery

An easy way to get the file names of an input form field:

 (function($) {
     var files = $('#myInputFile')[0].files,
         items = [];

     for (var i = 0; i < files.length; i++) {
         items.push(files[i].name);
     }

     // Getting file names in JSON array format
     JSON.stringify(items);
 })(jQuery);

 

Leave a Reply

Your email address will not be published. Required fields are marked *