- Create Account

Javascript Files in a folder

Forums > Other DHTML / JavaScript > Javascript Files in a folder
Author
Message

1) MrAndron Group: Members
Posts: 1 Joined: 21 Jan 2005 Location: Seattle IP: 24.16.--.--
Looking for some script that will show whats in a directory and list the files for download. Any help would be appreciated
Thanks
Fred

2) Angus Turnbull Group: Moderators
Posts: 4042 Joined: 7 Dec 2003 Location: New Zealand IP: 210.54.--.--
You need a CGI script. Try looking for a PHP, Perl or ASP script for the job; JavaScript from the browser can't easily access a list of files by itself (however you can use it to provide a nice interface to a list of files ;).

Good  luck - Angus.

3) ps3rips Group: Guests
IP: 62.3.--.--
I've been looking for somethig like this client side but activeX won't do it as its not a windows OS.
Is there another way?

It should be in javascript and be hosted on my site, then I browse there to get a list of directories - or drives. files etc?.


4) ps3rips Group: Guests
IP: 62.3.--.--
by the way I've also tried this code
"
write("The  contents of " + getCurrentFolder());

fileName = findFirstFile("*.*"); // Find the first file matching the filter
while(fileName.length)
{
    write(fileName);
fileName = findNextFile(); // Find  the next file matching the filter
}"

which  i can get to work if i use a javascript editor on a win machine but if I host it and call the file it will only give the server directories (I think) and I could use php for that.

I  thought Javascript could do it as its a cleint side language.

5) Angus Turnbull Group: Moderators
Posts: 4042 Joined: 7 Dec 2003 Location: New Zealand IP: 203.173.--.--
It is a client side language. It's also got a security model that is expressly designed to prevent web pages doing exactly what you're trying to achieve :).

If  you're on a LAN you might be able to sign scripts / rig browser privileges to allow it, otherwise you're looking at Java/ActiveX/etc to do it sorry.

- Angus.

Post a Reply:

You are not logged in, and will be posting anonymously as a guest. If you want to post using an account, please login at the top of this page.