Question

If I open a website, how I can view my own computer's contents on that site? I'm thinking Javascript, but how would I do this? This would be for like a file manager.

Example: Opening example.com and have a navigator for my computer's files.

Was it helpful?

Solution

For security reasons, you can't access a computer's file system from the browser via Javascript.

However, to answer your question literally, you could do this (in your console):

var input = document.createElement('input');
input.type = 'file';
document.body.appendChild(input);

Scroll to the bottom of the page and you'll see a file input field.

This will allow you to browse your computer's files from the webpage.

OTHER TIPS

Are you looking to access (potentially) ANY site's client/visitor's file system?
This is NOT possible, otherwise it would be a HUGE security breach.
If you could do it, anybody else could do it too. Imagine you yourself visiting some obscure site somewhere (it may be in pop-up even) and then some months later discovering that all your personal information that you had on your computer is available for sale.

This is what I understand

  1. You run example.com and want to show your filesystem to the public

    • Easy. Run apache/nginx with some weird document root and put all files there.
    • [CHECK] Not sure if you can run apache/nginx with / as document root.
  2. You run example.com and want to show visitors filesystem to himself

    • That will be a major security issue. JS cant do that in any way.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top