Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatically generate links depending on files available 1

Status
Not open for further replies.
Apr 27, 2006
126
GB
Hi,

I'm new to JS and have a (hopefully) simple query.

I publish some html files to a directory, lets call it \server\files for now.

I have a page in the \server directory called "main.html" which I have to manually populate links to the files in the \server\files directory.

Is it possible to generate a script (and if so, how?) to be implemented into the main.html file which checks which files are in the \server\files directory and generates links to all available files.

So for example. in the \server\files directory, there could be the following:

"Register file wc 260207.html"
"Register file wc 020307.html"
"Register file wc 090307.html"

These will change on a rolling basis, so it would be nice if the script could just check which files are there and generate links to them dynamically (would be nice if links could be shown as "Week commencing 260207" but it's not essential).

There will never be any other files in that directory other than the files I wish to display so I won't need any error checking for invalid files.

Any help would be greatly appreciated and thanks in advance.

________
clueless
 
If the file is on the server, use server side scripting. That's the easiest way to do it.

Client side Javascript (which doesn't include JScript ASP or Java Server Pages) only functions with the client computer (outside of AJAX). If you need to read something from the server, use ASP, PHP, ColdFusion, Java Server Pages, whatever technology the server has available.

Lee
 
the server has no technology available, this is why I need to perform it with Javascript afaik.

I was hoping that as files were stored in the same place as the source script it would be able to process the directory listing

________
clueless
 
But they're not stored in the same place as the computer where the browser actually runs the Javascript, are they? If you're using IE only, it's possible to work with files on the client computer using ActiveX objects, and there have been a number of threads in this forum on that.

You could also create a CGI executable that could do this, using either C/C++ or Visual Basic. There are a number of articles on the Internet on how to do this.

Remember that once the page is delivered to the client computer browser, the connection is broken between the client computer and server, and neither one is aware of the other without some kind of executable running on the page to create and maintain a connection.

Lee
 
ActiveX is not an option and not using excecutable files.

I can get it to return the directory listing a-la

Code:
window.location="/server/files"

but thats just fugly and so far from the ideal it's not even funny.



So are we saying that purely opening a page on a server, using javascript it is not possible to display a list of files on said server in the same directory as the javasript?

________
clueless
 
Nevermind anyway, it seems it can't be done without some form of server-side processing.

So back to good old VBA to genrate the html files and stick them on the server for me, quick and dirty and hoped it wouldn't come to this... :)

Thanks for effort though :D

________
clueless
 
never noticed those links you posted before (as we posted ath the same time).. but thanks for spending the time, I couldnt seem to find anything specific to what I wanted to do without calling activex so it looks like i'll just end up running a scheduled vba script overnight to sift through the folders

Cheers :)


________
clueless
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top