0

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.

tshepang
  • 12,111
  • 21
  • 91
  • 136
hexacyanide
  • 88,222
  • 31
  • 159
  • 162
  • Yes, but if PHP is server side, I don't think it can be done. I am meaning to get the files on my computer, such as when one clicks an upload button. – hexacyanide Aug 10 '12 at 15:44
  • Could you provide more details? In general, websites are blocked from opening files on clients' computers, for obvious security reasons. – ajd Aug 10 '12 at 15:45
  • 1
    Read this: [http://stackoverflow.com/questions/750032/reading-file-contents-on-the-client-side-in-javascript-in-various-browsers][1] [1]: http://stackoverflow.com/questions/750032/reading-file-contents-on-the-client-side-in-javascript-in-various-browsers – Stegrex Aug 10 '12 at 15:45
  • Read this: http://stackoverflow.com/questions/371875/local-file-access-with-javascript. If you are in HTML 5, you have options: http://www.html5rocks.com/en/tutorials/file/dndfiles/ – kakridge Aug 10 '12 at 15:46

3 Answers3

1

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.

Brian Ustas
  • 62,713
  • 3
  • 28
  • 21
0

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.

Germann Arlington
  • 3,315
  • 2
  • 17
  • 19
  • I was thinking listing them client side - not seen by the server. – hexacyanide Aug 10 '12 at 15:53
  • 1
    This http://www.antionline.com/archive/index.php/t-236772.html (https://www.google.co.uk/search?q=JavaScript+display+content+of+c%3A+drive) was possible some years ago. I did not try if it still works – Germann Arlington Aug 10 '12 at 15:58
0

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.
Jaseem
  • 2,236
  • 6
  • 28
  • 35