|
Alright, I've run into a problem. I'm setting up an image gallery and want to show a random image from each folder in the gallery on the main page. I can get the picture to show up, but my problem is it's always the same picture. I'm not real sure what I'm missing.
Here's the code:
Set fso = Server.CreateObjec("Scripting.FileSystemObject") Set rootFolder = fso.GetFolder(Server.MapPath(strFileUploadPath)) Set subFolder = rootFolder.SubFolders For each x in subFolder num=num+1 set fso2=Server.CreateObject("Scripting.FileSystemObject") set rootFolder2=fso2.GetFolder(Server.MapPath(strFileUploadPath & "\" & x.name)) LastMod = rootFolder2.DateLastModified
Response.Write (vbCrLf & " <td valign=""top"" align=""center"" bgcolor=""" & strTableColour & """ background=""" & strTableBgImage & """ class=""text"">") Response.Write ("<br />") Response.Write (vbCrLf & " <a href=""forum_photos.asp?" & x.name & """ class=""boldLink"">" & x.Name & "</a><br />") imgdir = strFileUploadPath & "\" & x.name
Set objFSO = Server.CreateObject("Scripting.FileSystemObject") Set objFolderObject = objFSO.GetFolder(Server.MapPath(imgdir)) Set objFSO = Nothing
Set objFileCollection = objFolderObject.Files Set objFolderObject = Nothing
intFileNumberToUse = Int(rnd * objFileCollection.Count) + 1
If objFileCollection.Count = 0 Then Response.Write ("<br />No Pictures In Gallery<br /><br />") Else intFileLooper = 1 For Each objFile in objFileCollection If intFileLooper = intFileNumberToUse Then Set objImageFileToUse = objFile Exit For End If intFileLooper = intFileLooper + 1 Next
Set objFileCollection = Nothing
strImageSrcText = imgdir & "\" & objImageFileToUse.Name
Set objImageFileToUse = Nothing
Response.Write ("<br />") Response.Write (vbCrLf & " <a href=""forum_photos.asp?" & x.name & """><img src=""/thumbnailimage.aspx?filename=" & strImageSrcText & "&width=" & ImgWidth &"&height=" & ImgHeight & """ border=""0"" align=""middle""></a><br / >") Response.Write ("<br />") End If Response.Write LastMod Response.Write (vbCrLf & " </td>") numGallery = numGallery + 1 If numGallery = 3 Then Response.Write (vbCrLf & " </tr>") Response.Write (vbCrLf & " <tr>") numGallery = 0 End if
Next If numGallery <> 0 Then Do While numGallery <= 2 Response.Write (vbCrLf & " <td valign=""top"" bgcolor=""" & strTableColour & """ background=""" & strTableBgImage & """ class=""text""> </td>") numGallery = numGallery + 1 Loop Response.Write (vbCrLf & " </tr>") End If
Any help would be greatly appreciated!
------------- http://www.spreadfirefox.com/?q=affiliates&id=179077&t=82">
|