SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast drnibbles's Avatar
    Join Date
    Oct 2001
    Location
    Australia
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Displaying pictures...

    Hi

    This code displays all the pictures in a defined folder as thumbnails. That works fine. But I would like to have it roll over onto a new page after a certain number of thumbs have been displayed and a back forward message.

    I cannot seem to get it to work. Any ideas!!!

    <%
    dim x,objFSO,objFolder


    strPath = "../projectnews/photos/infra/"

    Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
    Set objFolder = objFSO.GetFolder(Server.MapPath(strPath))


    close = "</a>"
    %>
    <CENTER>
    <h3>The Gallery</h3>
    <div align="left"><a href="<% = Request.ServerVariables("HTTP_REFERER") %>">Previous Page</a></DIV>
    <TABLE width="100%" cellpadding="8" align="center">
    <%
    for each x in objFolder.files
    if count mod 5 = 0 then

    %><TR><%
    end if
    %><TD><%
    count = count + 1
    blah = "<FONT SIZE=-3""><IMG SRC = ""../projectnews/photos/infra/" & x.Name & """ WIDTH = 100 HEIGHT = 80"">"
    image = "<A HREF=""../projectnews/photos/infra/" & x.Name & """ target=""_blank"">"
    Response.write image & blah & "<br>" & x.Name & close
    %></TR></TD><%
    next
    %>
    </TABLE>
    </CENTER>
    <%
    response.write "<CENTER><BR>There are " & count & " files in here</CENTER>"
    set objFSO=nothing
    set objFolder=nothing
    %>

    <div align="center"><a href="<% = Request.ServerVariables("HTTP_REFERER") %>">Previous Page</a></DIV>



    Cheers

  2. #2
    SitePoint Zealot BlitzCraig's Avatar
    Join Date
    Mar 2001
    Location
    Louisville, KY
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Check out this article:
    http://www.15seconds.com/issue/010308.htm

    Look at Solution 2, where they drop the recordset into an array and handle the paging accordingly.

    I imagine the solution would be the same only using a file list instead of an ADO recordset.
    Craig H. Rettig - Bitbucket Heaven
    To understand recursion, you must first understand recursion.

  3. #3
    SitePoint Enthusiast
    Join Date
    Feb 2002
    Location
    Birmingham, UK
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just a thought.. If you're going to use paging, does the FSO return files in a consistent order? If not, you may want to use a recordset object. It's been a while since I did much with the FSO, but off the top of my head, something like this may work:

    [VBS]
    ' create the recordset for filenames
    Set rs = Server.CreateObjecT("ADODB.Recordset")

    ' add the field for filename
    rs.Fields.Append "FileName", adVarChar, 255

    ' open the recordset
    rs.Open

    ' append each file to the recordset
    For Each File In objFolder.Files
    rs.AddNew File.Name
    Next

    ' sort the recordset (may be unnecessary)
    rs.Sort = "FileName ASC"

    ' you can now page the recordset using your preferred method.
    ' dhtmlgod posted some code in the thread "Funky Functions In ASP" to do this if you don't know of one

    ' clean up recordset
    rs.Close
    Set rs = Nothing

    ' clean up other objects
    [/VBS]

    It will slow things down a bit, but may be worthwhile considering. Also, bear in mind that it's not recommended to have more than 500 files in a folder on a windows operating system.

    HTH

    mullet


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •