简体   繁体   中英

Node.js get full path from user input

I'm trying to prompt the user to select a local folder with a <input type="file" webkitdirectory directory> in order to get the fullpath to said folder, but the value comes out as "C:\\fakepath\\folder"

Apparently, the "fakepath" is here for security reasons, but my app involves helping the user find files within his personal folders... How could I do that with such security measures blocking my way?

I could ask the user to manually (copy/paste, type) enter the path... But some users could have a hard time figuring out what a "path" is, let alone understanding how to find it and retrieve it.

Found a solution with document.getElementsByTagName('input')[3].files[0].path; (my file input is the fourth one in my HTML file, thus [3], and since the input only allows one file (/or folder in this case) .files[0]).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM