get a list of all folders in directory [closed]

So I have a file system that looks like this:

- 001
-- song.mp3
- 002
-- song.mp3
- 003
- 004
- 005
-- song.mp3

I was curious if it is possible to get a list of all of the folders names?

This javascript, html5, or even jQuery, I can not install anything.



he has a point in his question (HTML5)

I was curious if it is possible to get a list about all of the folders names? This javascript, or even jQuery, I can not install anything

Simply No , but not the Last Answer !

JavaScript (JS) is an interpreted computer programming language.It was originally implemented as part of web browsers so that client-side scripts could interact with the user, control the browser, communicate asynchronously, and alter the document content that was displayed.

There are 3 major types of JavaScript namely:

Client-Side JavaScript (CSJS) -- an extended version of JavaScript that enables the enhancement and manipulation of web pages and client browsers

Server-Side JavaScript (SSJS) -- an extended version of JavaScript that enables back-end access to databases, file systems, and servers

Core JavaScript -- the base JavaScript language

Client-Side JavaScript (CSJS) and Server-Side JavaScript (SSJS) are dependent on the core JavaScript and cannot work without it.

JavaScript and the DOM provide the potential for malicious authors to deliver scripts to run on a client computer via the web. Browser authors contain this risk using two restrictions. First, scripts run in a sandbox in which they can only perform web-related actions, not general-purpose programming tasks like creating files. Second, scripts are constrained by the same origin policy: scripts from one web site do not have access to information such as usernames, passwords, or cookies sent to another site. Most JavaScript-related security bugs are breaches of either the same origin policy or the sandbox.

There are subsets of general JavaScript — ADsafe, Secure ECMA Script (SES) — that provide greater level of security, especially on code created by third parties (such as advertisements).

I was curious if it is possible to get a list about all of the folders names? with HTML5

HTML5 provides FileSystem API which may solve your thirst , at least for know :)
Read the tutorial here :

another solution is to use the ugly browser Api, that i never ever recommends
Best Solution is to use a server side language like php


Are you trying to get the client's file system? If so, web browsers usually prohibit this type of behavior for security reasons.

If you're trying to list things on your web server, this can't be done without AJAX since JavaScript runs on the client's machine. You would need to have some server code to list the directory for you, but this can pose a potential security risk.

I think your best bet is to run server side code to list the directory, it's not the safest thing to do that on client side code.


If you are asking on client side Javascript, Yes, we can access in Mozilla Firefox using File API, i don't know other browsers.


You could definitely accomplish this, as @Tariq said, with some serverside code, like php. you could submit directory paths in relation to the root via ajax (check out the jquery $.post() @ ).

  if (isset($_POST['submit'])) {
  //capture post varibles, sanitizing of course.
  $dir = "";
  $dir = $_POST['input'];

    $dh  = opendir($dir);
    while (false !== ($filename = readdir($dh))) {
      $files[] = $filename;
//now, do stuf with files



Here's the output:

[0] => .
[1] => ..
[2] => bar.php
[3] => foo.txt
[4] => somedir

Hope this helps.


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.