如何拖放目录并仅获取其路径? [英] How to drag and drop directory and get only the path of it?
本文介绍了如何拖放目录并仅获取其路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我该如何在Windows中拖放目录并获取目录的路径-就是为了不让我自己一直写路径(有时它真的很长)。
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.
推荐答案
Chome上的输入类型文件支持拖放目录,但是我认为您将无法轻松获得完整路径,由于安全原因。
以这个例子为例:
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/
这篇关于如何拖放目录并仅获取其路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文