How to drag and drop directory and get only the path of it? [closed]

走远了吗. 提交于 2019-12-13 02:26:12

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!