% On Error Resume Next Randomize Timer strPath = Request.QueryString("path") Const strValid = ".jpg" ' make sure we have a trailing slash in the path If Right(strPath,1) <> Chr(47) Then strPath = strPath & Chr(47) ' get the physical path of the folder strPhysical = Server.MapPath(strPath) ' get a File System Object Set objFSO = Server.CreateObject("Scripting.FileSystemObject") ' create a folder object Set objFolder = objFSO.GetFolder(strPhysical) ' get the files collection Set objFiles = objFolder.Files ' enumerate the files collection looking for images For Each objFile in objFiles strFile = LCase(objFile.Name) If Instr(strValid,Right(strFile,4)) Then ' add vaild images to a string of image names strFiles = strFiles & strFile & vbTab End If Next ' split the image names into an array strImages = Split(strFiles,vbTab) if UBound(strImages) > 1 then imagedisplayed=strPath & strImages(Int(Rnd(1)*UBound(strImages))) If Request.QueryString("method")="html" then %> <% RandomLink=request.servervariables("script_name")&"?"&request.querystring Response.Write "
" Response.Write "" %> <% else Response.Redirect imagedisplayed end if%>