Forum Moderators: open
I'm guessing the page is generated on the fly but I can't find the script that performs this, so that I can edit the HTML it produces. Any ideas?
Thanks in advance
As long as its one of the default page names then it will be used instead of a simple directory listing - giving you absolute control over the appearance of that page...
- Tony
One thing though and PLEASE correct me if I'm talking rubbish but........If I wanted to write my own asp I'd surely have to put it in the same directory as and call it the same as, the script that it runs presently or it wont pick it up. In which case I could just edit the current script. However I don't know where it is!
<%
Dim objFSO, objFile
Dim sMapPath, objFolder
'Create File System Object to get list of files
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Get The path for the web page and its dir, change this setting to view different directories!
sMapPath = server.mapPath("./.") ' this means the current directory
'Set the object folder to the mapped path
Set objFolder = objFSO.GetFolder(sMapPath)
' Then for each file in the object we loop through and print the file and when it was last modified
For Each objFile in objFolder.Files
' Print out a link to the file
Response.Write "<tr><td><a href="""&objFile.Name&""">"
Response.write objFile.Name &" </a></td><td> "& objFile.DateLastModified ' the file name and its date
Response.write " </td></tr>" ' close the tags
Next ' Loop back
' Clear the objects
Set objFSO = Nothing
Set objFolder = Nothing
%>
Just a few tips:
1. Put the ASP in a separate directory to the one you want to list or the ASP will get listed too.
2. Wherever you put the ASP make sure you change the line
sMapPath = server.mapPath("./.") to the directory you want to list eg sMapPath = server.mapPath("./this_directory") AND change the line <a href="""&objFile.Name&"""> to that directory too eg <a href=""this_directory/"&objFile.Name&""">
3. You can call the ASP anything you like and point to it but you could also, as Dreamquick stated, call it one of the default name such as index.asp or default.asp so that the server automatically runs it.
4. You might want to change the HTML code a bit if you don't want it in a table however you'll need to put a <br> at the end to get the format correct.