% dim strBasePath dim strImage() dim x dim objFolder dim objFSO dim fso dim n dim imgsrc dim strFileName dim strHyperlinkPath x=0 strBasePath="/images/banners/" 'path where your random images reside CHANGE THIS TO MEET YOUR NEEDS!!! 'create the FSO Set fso = Server.CreateObject("Scripting.FileSystemObject") Set objFolder = fso.GetFolder(Server.MapPath("/images/banners/")) 'CHANGE HERE TOO !!!!!!!!!! 'loop through every file in the current folder For Each objFile in objFolder.Files strFileName=objFile.Name 'get filename strHyperlinkPath = strBasePath & strFileName ReDim Preserve strImage(x) strImage(x) = strHyperlinkPath x=x+1 Next Randomize x = UBound(strImage) + 1 n = int(rnd * x) n=cstr(n) imgsrc = strImage(n) set fso = Nothing set objFolder = Nothing set objFile = Nothing Function RemoveSpaces(strString) strHyperlinkPath = Replace(strHyperlinkPath," ","%20") End Function%>
|