Sumit Sarkar
Sumit Sarkar

Reputation: 169

How to get the path of selected folder in javascript or node js

I want to get the path of selected folder. Here is my code:

<input style="display:none;" id="fileDialog" type="file" webkitdirectory />

var chooser = document.querySelector('#fileDialog');
    chooser.addEventListener("change", function(evt) {
      console.log(this.value);
    }, false);
    chooser.click(); 

Using this code i'm getting a fakepath.

Is there anyway in node.js,so i can get the path of my selected folder. I'm using express framework in node.js.

Upvotes: 1

Views: 1623

Answers (1)

T.J. Crowder
T.J. Crowder

Reputation: 1074028

There's no way for you to get the path of the file selected in an input type="file" at all, full stop. Not on the browser, and not transmitted to the server for you to use in Node/Express. That information is simply not available to you. Browsers let you know the name of the file, but that's it.

Upvotes: 1

Related Questions