问题
How can i drag and drop directory in windows and get the path of the directory - that is in order to not to write the path by myself all the time (sometimes its really long).
I tried to look for a solution but couldn't find as most drag and drop that relate to directory or files just getting the directory file list.
回答1:
Dropping directories is supported in input type "file" on Chome, however I don't think you will be able to get the full path easily, due to security reasons. Take a loot at the example:
var dropzone = document.getElementById('dropzone');
dropzone.ondrop = function(e) {
var length = e.dataTransfer.items.length;
var entry = e.dataTransfer.items[0].webkitGetAsEntry();
if (entry.isDirectory) {
alert(entry.fullPath);
}
};
https://jsfiddle.net/zp574g63/1/
来源:https://stackoverflow.com/questions/33230544/how-to-drag-and-drop-directory-and-get-only-the-path-of-it