View Full Version : File Manager with Javascript

01-31-2007, 11:36 AM

I am trying to include a FileManger part in a HTML webpage by using Javascript and ActiveX.
Basically it would be a normal page where I would call the ActiveXObject "Shell.Application" and then have a functionality similar to the one used in the BrowseForFile method.

The only problem is that the BrowseForFile method opens up a dialog box and would need it to open in an IFrame inside my webpage
(have a regular HTML page that displays in a corner the contents of a folder on a share and from where you can copy paste files).
Is such thing possible?Or is there an alternate solution apart from this ActiveX,that could provide the same functionality ( by only using client side code - I found something done in php).

Thank you,

01-31-2007, 05:33 PM
Well, javascript isn't exactly meant for this sort of thing. If you did have access to server side you could use AJAX.

01-31-2007, 07:17 PM
probably could be done if roll your own code.

Starting with get sub folders, get all files etc.

fso = new ActiveXObject("Scripting.FileSystemObject");
n = fso.GetFolder(mycurrentfolder);
e = new Enumerator(n.SubFolders);
for (;!e.atEnd();e.moveNext())
x = e.item();
document.getElementById('destfolder').options[i]= new Option (x, x); //example that adds the folders to a <select>

x is a folder objt so x.name gets you it's name without path.

02-01-2007, 11:01 AM

I actually need to be able to read the contents of an NT share - so an Ajax approach of this would be fine as well.
I don't only need to be able to iterate through folders - but also copy/paste files.As I said - very similar to a file manager opened by the BrowseForFolder method in the Shell Object.

02-01-2007, 12:23 PM
Although I don't see why you just don't leave this down to the shell in the first place. What's wrong with \\server\share and letting explorer handle it?

02-01-2007, 09:03 PM

I must admit that indeed, that is the most simple aproach but it only works properly in IE - it has some issues when attempting to open a file from a folder in Firefox and also displays a "Index of" title.
So I am trying to see if there is a workaround this.
If not, I will probabilly use it - the issue here is to fine tune a feature.