[Last Call] Learn how to a build a cloud-first strategyRegister Now


Display local folder content (sub folders & files (not hidden)) using JavaScript

Posted on 2014-08-04
Medium Priority
Last Modified: 2016-05-23
Guys, slowly getting a solution that works for me via here, but still not completely there.  I work on a helpdesk and want to create a webpage that will display a htm/html page showing the content of multiple networked folders, such as

VAR: Folder path
Folder 1
Folder 2
Doc 1
Doc 2
Doc 7

VAR: another folder path
Folder 1
Folder 2
Doc 1
Doc 2
Doc 7

with the folder and document links clickable to open in a new page.  Someone on here has helped part way, but only to display the content (files) of one folder.

This is what I have so far...

<script src="scripts/filelist.js"></script>
<BODY topmargin="0" leftmargin="0" onLoad="Scan()">
<input size=50 type=text value="c:\" id=path name=path class="Field" >
<div id=outPut_c></div>


Open in new window

var Fo =new ActiveXObject("Scripting.FileSystemObject");
var StrOut = new String();
var FileName = new String();
var Extention = new String();
var FilePath = new String();

function FindFile(FOo)
	var FSo = new Enumerator(FOo.Files);
		if(FileName == "*" ||  FSo.item().name.slice(0,FSo.item().name.lastIndexOf(".")).toLowerCase().indexOf(FileName)>-1)
			if(Extention == "*" || FSo.item().name.slice(FSo.item().name.lastIndexOf(".")+1).toLowerCase().indexOf(Extention)>-1){
			if (FSo.item().Attributes & 2 ){}
				StrOut += "<tr "+ ((i%2)? "":"bgcolor=#FFFFFF")  +"><td width=50%><font class=find>" + '<a href="file:///'+FSo.item().name+'">'+FSo.item().name + "</a></font></td><td width=25%><font class=find>" + FSo.item().type + "</font></td><td width=50%><font class=find>"+ String(FSo.item().size/(1024*1024)).slice(0,3) +" MB</font></td></tr>";

function Scan()
	if(path.value.length>0 && Fo.FolderExists(path.value)){
		StrOut = "<table border=0 width=100% cellspacing=0>"
		outPut_c.innerHTML = StrOut+"</table>";
	else alert("Insert Correct Path Address");

Open in new window

Is it possible to call multiple folder contents and display in a webpage as it would seem the

Open in new window

will only overwrite the existing display.
Question by:creativepresence
  • 2

Author Comment

ID: 40238993
Obviously, if there is a better way to display mutliple folder content in a webpage, where the user can open the displayed folders\files.
LVL 29

Accepted Solution

fibo earned 2000 total points
ID: 40245747
- You might consider looking at a ready-to-run existing solution such as http://extplorer.sourceforge.net/ (written in js and php)

- you need to work at the DOM-level, so that your js codes adds content to your page innerHTML
-- initialize outPut_c.innerHTML, eg
            outPut_c.innerHTML = "<h1>Listing of files and directories</h1><hr>";

-- change
            outPut_c.innerHTML = StrOut+"</table>";
            outPut_c.innerHTML += StrOut+"</table>";
LVL 29

Expert Comment

ID: 41039481

Where do you stand currently on the issue?

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question