Can I find and download a specific list of files using jQuery or JavaScript?

I would like to do a procedure that will find a predetermined number of files that will always be found in one place and will always have the same file names. Is it possible to find these files and then upload them to a web server with minimal user intervention?

Ideally, I would like the user to click the button only once, and then locally locate these files, and then upload them to the web server. At the beginning, I was going to use the form and make the user click the “Search File” window for each file, but currently I need to upload 20 small files at the same time, so the approach will be quite time-consuming.

Any pointers or ideas?

+4
source share
2 answers

Can I find these files and then upload them to a web server with minimal user intervention?

The user must select user files from the user file system with each user action in the element input type="file". Custom files must be available in the object FileListin the event onchange.

If all files are saved in one directory and the browser supports the attribute directory, the user should be able to download the folder selected by the user.

Chrome, , webkitdirectory; firefox , , multiple allow_dirs firefox.

.

document.querySelector("input").onchange = function() {
  console.log(this.files)
}
<input type="file" directory="directory" allow_dirs="allow_dirs" webkitdirectory="webkitdirectory" />
Hide result
+3

, , javascript . , -, , , .

script , , zip , zip .

0

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


All Articles