Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get fullpath of dropped folder from file system

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

I have done something like this

<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

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

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

like image 277
Shashikant Bhapkar Avatar asked Nov 27 '22 19:11

Shashikant Bhapkar


1 Answers

  • getAsFile does not expose a path-Property. -- not in Chrome -- in IE even dataTransfer.items is unsupported.
like image 130
a-pr Avatar answered Nov 29 '22 09:11

a-pr