This feature may upload folder there is a demand in the web end, here a brief introduction usage.
Currently, only Google browser as well as Microsoft Edge support according to the folder to upload, you can look at a specific Web version of Baidu cloud disk upload button in Firefox on by file upload support, and in Google and Edge, will give to provide users with a drop-down, lets the user choose to upload a file or folder to upload according to according to documents.
And in the Google browser, support is not without conditions, a property must be added on the input: will be supported after webkitdirectory.
Plus the effect is such
Attach a file folder with a single file upload example
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script> </head> <body> <input id="fileFolderMore" type="file" name="file" webkitdirectory/> <input id="fileFolderOne" type='file' name="file"> </body> <script> $('#fileFolderMore').change(function(e){ // console.log(e) var files = e.target.files; console.log(files) }) $('#fileFolderOne').change(function(e){ // console.log(e) var files = e.target.files; console.log(files) }) </script> </html>
上面文件夹选择后会显示文件夹的路径的
上传的话可以用formData,也可以用form表单。