Link to home
Create AccountLog in
Avatar of WaldaInc
WaldaInc

asked on

Folder Browser in JavaScript

I think I know the answer to this, which is no, but I need to ask anyways.

I need a javascript folder browser for a web page. I don't want the input type="file", because I want to select a folder on the server. I've tried a few items I've found on the net, none work.  If this can be done without javascript, cool.

I know there are a ton of security issues involved with this, but this will be a web site behind the firewall so it should be ok.

Thanks.
Avatar of WaldaInc
WaldaInc

ASKER

Let me clarify a bit more.

I just need to get a folder name.  The stuff I want to do once I get that folder name can be done my me impersonating the admin user.

Again, I know this is a security issue, but if it can be done that would be great.

Did you see this one? There's code using an ActiveX control here (probably only works in IE):
http://www.tek-tips.com/faqs.cfm?fid=5201
The server is a big place. How will you know where to look for "a folder"?

I would make an Ajax request, and pass a list of folders up to the client.
Thanks Lolly-lnk.  However, I can't get that code to work.  Mabe I'm missing something simple.

Badotz, I have searched and I don't see any AJAX code that would get me a list of folders.

I'm back to the idea this just can't be done. Unfortunate, but understandable.

>>I'm back to the idea this just can't be done.

Of course it can be done. The client tells the server to fetch a list of folders (from the server). Straightforward.

Now, if you want a list of folders on the CLIENT, that is another matter. The FileSystemObject can be used, but it brings up ActiveX warnings, or isn't allowed to run at all.

Still, the FileSystemObject on the SERVER works like a charm.
oops, am I missing something here?  Javascript is a CLIENT-ONLY language -- it only affects the display in the users browser.  Any file structure on a server is out of bounds to a client language.  You need a server language like PHP, ASP or in your case, what you really want is an FTP program -- they are designed from the get-go to show tree structures on the server.  It is impossible with just plain javascript.
>>Javascript is a CLIENT-ONLY language

Since when? I use it on the client, and all of my server code is javascript, too.
You're the first I have heard of running javascript on a server to do server functions.  What do you do with javascript on a server?  Or do you mean your server pages simply send javascript to the browser?
Whatever you can do in PHP, I can do in javascript. Well, you could, too ;-)

I'm learning PHP as we type, but I'm not ready to convert anything just yet.

I made the leap from VBscript to javascript, and found I could write JS on the server as well as on the client. Being naturally lazy, I never learned another way.
PHP is well worth learning, probably the most intuitive server language there is.

I've never heard of anyone using JS on servers.  When I and others make the client-only comment on EE, realize we need to make a clear distinction,  because many people think that javascript in a browser window can make changes on the server, or at least act like a form and interact with a server.  

It is important to make the distinction to them, so I will continue to say what I did here -- hope you can accept that.
ME? I could care. But I know the truth - javascript runs on the server.

Here at EE, I strive to make the distinction using the words "client" and "server".

We both know that what happens on the client, stays on the client - unless Ajax is involved. Here again, there is a separation, but it is somewhat blurred.

Like if you stare at "Web 1.0" long enough, you will eventually see "Web 2.0" ;-)
ASKER CERTIFIED SOLUTION
Avatar of WaldaInc
WaldaInc

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer