How to get a list of files selected as a result of a file upload

I have an element (which allows you to upload multiple files). I would like to use javascript / jquery to get a list of the files that were selected for download. Is it possible?

The item looks like

<input type="file" name="files[]" multiple/> 

I get files with a Play Framework controller (Java), but this is not very useful for the question.

+4
source share
1 answer

You can get the list from the "files" property of the input element. I think this link may help you. Does javascript get the number of files and their names from a file input element with multiple attributes?

Example:

 $files = $('#fileInput').files; for (var i=0, l=files.length; i<l; i++) { console.log(files[i].name); } 
+8
source

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


All Articles