<% Function RandomImage(strPath) Randomize() If Right(strPath, 1) <> Chr(47) Then strPath = strPath & Chr(47) strPhysical = Server.MapPath(strPath) Set objFSO = Server.CreateObject("Scripting.FileSystemObject") Set objFolder = objFSO.GetFolder(strPhysical) Set objFiles = objFolder.Files For Each objFile in objFiles strFile = LCase(objFile.Name) strFiles = strFiles & strFile & vbTab Next strImages = Split(strFiles, vbTab) If UBound(strImages) > 1 Then RandomImage = strPath & strImages(Int(Rnd(1)*UBound(strImages))) End If End Function %>
The Result:
random image asp Server.MapPath graphics FileSystemObject fso