如何从文件系统中获取已删除文件夹的完整路径

问题描述:

我正在尝试在我的应用程序中实现拖放操作,这需要删除文件夹的完整路径。

I am trying to implement drag n drop in my application, which need the full path of folder being dropped.

我做过类似的事情

<html>
<head>
<style>
#dropzone {
    height:200px;
    width: 200px;
    border: 10px dashed #0c0;
    background-color:cyan;
}
</style>                  
</head>
<body>

<div id="dropzone" droppable="true" ondrop ="drop(event)" ondragenter="return false" ondragover="return false">
</div>

<script type="text/javascript">  
function drop(e) {
    e.stopPropagation();
    e.preventDefault();
    var length = e.dataTransfer.items.length;
    for (var i = 0; i < length; i++) {
        var entry = e.dataTransfer.items[i].webkitGetAsEntry();
        if (entry.isDirectory) {
            alert(entry);//here i need to get path of folder being dropped.
        }
    }
}
</script>
</body>
</html

如果我提醒 e.dataTransfer。文件[i] .name 里面 for loop 然后它只显示文件夹的名称,但不显示它的路径。

If I alert e.dataTransfer.files[i].name inside for loop then it only show name of folder but not it's path.

javascript是否允许访问本地文件系统?或者任何解决方法。

Does javascript allow access to local file system? OR any workaround for this.


  • getAsFile 公开路径属性。
    - 不在Chrome
    中 - 在IE中甚至不支持dataTransfer.items。

    • getAsFile does not expose a path-Property. -- not in Chrome -- in IE even dataTransfer.items is unsupported.