0

What I am trying to achieve is to open a directory (like "File Explorer" on windows ) and select path to a folder. Not to a file!

I have tried webkitdirectory, directory attribute with type="file" but doesn't work.

<input type="file" webkitdirectory mozdirectory directory />

Would appreciate to see some simple example how can this be done.

EDITED:

I just need to return the path to the folder and not files under the folder. Example: C:\Documents\Test - this is correct

C:\Documents\Test\someFile.csv - incorrect

enter image description here

Roman
  • 1,118
  • 3
  • 15
  • 37
  • Out of interest how would you use that information in your app? – Andy Jun 10 '22 at 12:31
  • This will be used to show where the user wants to store migrated data. Currently the user has to insert the path manually. – Roman Jun 10 '22 at 12:35
  • 1
    try this . Duplicate of [question](https://stackoverflow.com/questions/2809688/directory-chooser-in-html-page) – Akhil Jun 10 '22 at 12:49
  • 1
    Does this answer your question? [Directory Chooser in HTML page](https://stackoverflow.com/questions/2809688/directory-chooser-in-html-page) – Emanuele Scarabattoli Jun 10 '22 at 12:50
  • 2
    This will upload all files under the folder. But what I want is to get only a path to the folder: https://codepen.io/matuzo/pen/KOdpmq – Roman Jun 10 '22 at 12:56
  • This is duplicated question https://stackoverflow.com/questions/69393230/browse-folder-path-in-react – Roman Jun 10 '22 at 13:09
  • I found out that this is not possible due to security reasons https://stackoverflow.com/questions/69236490/how-do-you-get-the-selected-directory-path-from-file-system-access-api-window-sh – Roman Jun 13 '22 at 07:42

0 Answers0