This could possibly be re-written for javascript but would have to be run server side in order to create the FileSystemObject to get at the server folder.
This code does not have to point at a web server folder for the images, it could look at a server folder elsewhere on the network but the IUSR_machinname account would have to have access to that network folder and the methods of authentication be matched between the file server and the IIS server.
The commented lines are there to show what other file attributes you can easily get at.
The If statement that filters for GIF and JPG file types can be modified to include other types as well, this is just what I put in for testing.
Essentially the code just looks at the file folder and loops through each file in the folder testing to see if it's file extension matches one in the IF statement and if it does it spits out the name on the screen. You can instead insert the name into an array to be used later, immediately generate the <IMG tag with that path/filename for it's source, use an image pre-load script to retrieve the image into memory for future use, etc.
The main point of this code is to allow you to read ALL images in a folder of specified types without having to know the filenames ahead of time and eliminate the need to hard-code the names into your script or write them into some sort of control file.
Code:
<%
Dim fso
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Dim rootFolder
Set rootFolder = fso.GetFolder("\\servername\inetpub\[URL unfurl="true"]wwwroot\myfolder\images\")[/URL]
Dim files
Set files = rootFolder.Files
For Each file in files
If file.Type <> "GIF Image" AND file.type <> "JPG Image" Then
Response.Write "FileName: " & file.Name & "<br>"
End If
Response.Write UCase(file.Type)
' Response.Write "Attributes: " & file.Attributes & "<br>"
' Response.Write "Type: " & file.Type & "<br>"
' Response.Write "Size: " & file.Size & "<br>"
' Response.Write "ShortName: " & file.ShortName & "<br>"
Next
Set files = Nothing
Set rootFolder = Nothing
Set fso = Nothing
%>
Paranoid? ME?? WHO WANTS TO KNOW????