1

I am planning to create an app using html5 file api and javascript to take directory path as input and be able to process (search for a text) all files in that directory and sub directories.

currently I am doing it using batchscript, What are constraints/obstacles doing it using HTML/javascript.

2
  • The HTML 5 File API can't take a directory path as input… Commented Mar 10, 2016 at 19:10
  • are you searching file names or file contents? use <input type=file webkitdirectory multiple> to get a whole folder into browser JS. Commented Mar 10, 2016 at 19:20

1 Answer 1

3

In short: You can't to that automatically.

Access the local filesystem from any browser is blocked for security reasons. Reason: Imagine any website being able to access the files on your filesystem.

Read this: Local file access with javascript

Maybe you want to rephrase your question and say what you actually want to acheive.

You can access simple file information using the user's input and using <input type=file>. But the user would require to do the following steps:

  1. Click the "Browse button" (a file dialogue appears).
  2. Navigate to the requested folder.
  3. Select 1 or many files.
  4. Click "Open".

Mozilla has documented this well with an example: https://developer.mozilla.org/en/docs/Using_files_from_web_applications#Example_Showing_file(s)_size

Sign up to request clarification or add additional context in comments.

2 Comments

user can can opt-in to allow file access using an <input type=file>
It is possible to read local directories using the Filesystem API in client-side JavaScript.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.