-1
<!DOCTYPE html>

<html>
<body>
<div align="center" style="width:800px" >

LocalShare:

<input type="file" id="FileUpload" onchange="selectFolder(event)" webkitdirectory mozdirectory multiple />

<p id="demo"></p>

<p id="demo1"></p>
<script>
function selectFolder(e) {
    var txt = "";
    var theFiles = e.target.files;
    var relativePath = theFiles[0].webkitdirectory;
    var relativePath = theFiles[0].webkitRelativePath;
    var x = document.getElementById("FileUpload").value;
    document.getElementById("demo").innerHTML = x;
    document.getElementById("demo1").innerHTML = relativePath;
    var folder = relativePath.split("/");
    alert(folder[0]);
}
</script>
</body>
</html>

Output of the above code is:

C:\fakepath\filename

foldername

Here it is displaying folder name and path name. It is taking default value as "fakepath" but I need to find out exact path!

Nisarg Shah
  • 14,151
  • 6
  • 34
  • 55
Manu
  • 11
  • 1
  • 3
  • 1
    Correct me if I'm wrong but I'm not sure if this is possible using JavaScript for security purposes. – Script47 Aug 29 '17 at 09:59

1 Answers1

1

Well, Earlier it was allowed but due to security reason browser doesn't allow us to get client machine's internal details.