3 Replies - 933 Views - Last Post: 02 March 2014 - 07:43 PM

#1 daydr3am3r  Icon User is online

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 106
  • Joined: 10-April 09

List files & folderd from specified path

Posted 26 February 2014 - 03:47 AM

Hi guys,

I'm not sure this is the right place to ask (I was thinking of asking in the JS forum) but here it goes.

I am curious if it is possible to list local files and folders in browser as an expandable list.

What I am trying to do is list the content of certain local folders and to access their content (that content is mostly consisting in web projects).

Let's say I have the root "/" and inside that I have certain folders(f1, f2 etc.). Those folders will also have their sub folders and so on (sf1, sf2 etc/).

The structure will be something like this:


and so on.

Since I only have a few folders I want to access like this I'm happy with just giving the path manually to any folder I want, without the need to access the entire root folder.

I am aware of the fact that this is possible in Php but that is limited to the localhost server folder (www, htdocs etc.) and its content.

Is this possible? I know there are obvious security problems here and somehow I suspect it's not that easy (if possible at all) but I'm hoping.
Could you guys give me some info?
Is there any language/API that can do this?

Sorry for the lack of code but it's obviously why I cannot post any.

This post has been edited by daydr3am3r: 26 February 2014 - 03:49 AM

Is This A Good Question/Topic? 0
  • +

Replies To: List files & folderd from specified path

#2 Dormilich  Icon User is online

  • 痛覚残留
  • member icon

Reputation: 4085
  • View blog
  • Posts: 12,818
  • Joined: 08-June 10

Re: List files & folderd from specified path

Posted 26 February 2014 - 07:22 AM

you can do that for specific folders at least. there’s a similar example at MDN using the File APIs. you should be able to modify it to your needs.

for nested folders I’m not so sure. could still be subject to security restrictions (otherwise anyone could read your files via a website).

This post has been edited by Dormilich: 26 February 2014 - 07:25 AM

Was This Post Helpful? 0
  • +
  • -

#3 FerretHolmes  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 41
  • View blog
  • Posts: 167
  • Joined: 12-November 12

Re: List files & folderd from specified path

Posted 26 February 2014 - 08:49 AM

Do you mean something like this?
Was This Post Helpful? 0
  • +
  • -

#4 SunshineInABag  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 01-March 14

Re: List files & folderd from specified path

Posted 02 March 2014 - 07:43 PM

It is possible to do this through PHP, either by creating your own recursive function that uses scandir or using the built-in RecursiveIteratorIterator. For this, you can specify the path in the code, then it can display the resulting files and folders in the browsers. Using Javascript and CSS, you can create and add to the expandable list. Using PHP will require a web server for it to run, such as Apache.

In terms of pure CSS and HTML, this isn't possible. It's possible to use pure Javascript using the FileSystem API, including DirectoryEntry and DirectoryReader. The major setback is that only Chrome has wide support for this, according to this article. The most recent versions of other browsers may or may not work.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1