DaMaxContent DaMaxContent - 1 year ago 67
Javascript Question

Read file structure with client-JS when the client is the server?

In google chrome and many other browsers, you can pull up website files locally (in chrome you do this with the

file://
url prefix).

Is it possible to read the local file system with client-side JS if the website was loaded from the local file system? or is this not possible period?

Answer Source

Is it possible to read the local file system with client-side JS if the website was loaded from the local file system?

You can use filesystem: URL scheme.

See Debugging the Filesystem API

filesystem: URL FTW. It’s handy to open the filesystem: URL for the root DirectoryEntry of your app’s origin. What does that mean? For example, if your app lives on www.example.com, open filesystem:http://www.example.com/temporary/ in a new tab. Chrome will show a read-only list of the files/folders stored your app origin. For more info on filesystem: URLs, see http://www.html5rocks.com/en/tutorials/file/filesystem/#toc-filesystemurls.

You can also enable Filesystem inspection at DevTools to view folders and files at Resources -> FileSystem