How to upload a drag-and-drop folder at the front end

if you click to upload a folder, you can add webkitdirectory attribute to input, but drag and drop the upload folder, I can"t find a satisfactory answer all over the network. The closest answer is to get the data. Here is demo: https://wicg.github.io/direct...

.

but cannot get the path to the file, that is, webkitRelativePath

this problem has been bothering me for a long time, so I have to turn to the community for help. If it is impossible to achieve, please let me know, or if there are other ways, please do not hesitate to give me advice.


old problem. The web page in the browser can not get the path, because the design goal of the browser is to become a black box to restrict these operations that have direct access to system resources, so to take the path, either become a browser plug-in, or simply run locally (such as node).


  

I have the same requirements, and the problem is the same as yours. If you just select a folder, add webkitdirectory to input to get the path of the files in it relative to the folder. But if you drag and drop the folder, the webkitRelativePath is empty. Excuse me, how did you solve it later? Baidu network disk can achieve drag-and-drop folder upload, retain the folder structure.

Menu