Displaying the images in the folder

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sonasang
    New Member
    • Sep 2007
    • 27

    Displaying the images in the folder

    Hi ,
    I am creating a web page in ASP. I will place some images in the folder,
    The images placed in the folder should be disaplayed. I am having the two button in the web page if I click next button then the next image should be dispalyed, If i click prev button then the prev image in the folder shd be displayed.The images are not static... its if today i hav 10 images afetr some time i amy hav 15 images....

    Pls help me...

    Thanks in advance
  • Sonasang
    New Member
    • Sep 2007
    • 27

    #2
    Displaying the images in the folder

    Displaying the images in the folder
    --------------------------------------------------------------------------------

    Hi ,
    I am creating a web page in ASP. I will place some images in the folder,
    The images placed in the folder should be disaplayed. I am having the two button in the web page if I click next button then the next image should be dispalyed, If i click prev button then the prev image in the folder shd be displayed.The images are not static... its if today i hav 10 images afetr some time i amy hav 15 images....

    Pls help me...

    Thanks in advance
    Last edited by jhardman; Dec 5 '07, 07:50 PM. Reason: merged threads, sorry if that makes the replies appear discontinuous

    Comment

    • shweta123
      Recognized Expert Contributor
      • Nov 2006
      • 692

      #3
      Hi,

      To display the images on web page , you can use FileSystemObjec t.

      <%

      Dim obj
      Dim folder
      Dim file

      '''''Create FileSystemObjec t

      Set obj = Server.CreateOb ject("Scripting .FileSystemObje ct")

      '''''''Get the folder folder for your image path

      Set folder = obj.GetFolder(f olderpath)

      '''''''Get each file in that folder

      For Each file In folder.Files%>
      <img src =<%= file.path%>>
      <%Next%>

      Originally posted by Sonasang
      Displaying the images in the folder
      --------------------------------------------------------------------------------

      Hi ,
      I am creating a web page in ASP. I will place some images in the folder,
      The images placed in the folder should be disaplayed. I am having the two button in the web page if I click next button then the next image should be dispalyed, If i click prev button then the prev image in the folder shd be displayed.The images are not static... its if today i hav 10 images afetr some time i amy hav 15 images....

      Pls help me...

      Thanks in advance

      Comment

      • Sonasang
        New Member
        • Sep 2007
        • 27

        #4
        Hi Swetha,

        Thanks a lot for ur reply and help....
        Its working fine....

        It is displaying all the images in the same page......

        Thanks a lot

        Comment

        • Nicodemas
          Recognized Expert New Member
          • Nov 2007
          • 164

          #5
          It's a good solution, but he did say he wanted previous/next buttons.

          this should work, though, i did not test it.

          Code:
          <%
          '//----------------------------------------------------
          '// declare some constants and variables
          '//----------------------------------------------------
          dim oFileSystem, oFolder, nFile, i, aFilenames, lookUp
          
          i = 0
          const IMAGE_DIRECTORY = "/path_to_my_image_directory/"
          
          '//----------------------------------------------------
          '// set up FSO
          '//----------------------------------------------------
          set oFileSystem = server.createobject("scripting.filesystemobject")
          
          '//----------------------------------------------------
          '// get all images in image directory, store filenames
          '// in array
          '//----------------------------------------------------
          set oFolder = oFileSystem.getFolder(server.mappath(IMAGE_DIRECTORY))
          
          '//----------------------------------------------------
          '// resize array to fit number of files in directory
          '//----------------------------------------------------
          redim aFilenames(oFolder.files.count - 1)
          
          '//----------------------------------------------------
          '// loop through files in folder, assign each to
          '// index in array
          '//----------------------------------------------------
          for each nFile in oFolder.files
             aFilenames(i) = nFile.name
             i = i + 1
          next
          
          set oFolder = nothing
          set oFileSystem = nothing
          
          '//----------------------------------------------------
          '//determine which image the user wants to look at
          '//----------------------------------------------------
          if request.querystring("pic") <> "" and isnumber(request.querystring("pic")) then
             lookUp = cint(request.querystring("pic"))
             '//----------------------------------------------------
             '// make sure the value of lookUp doesn't break
             '// our array bounds
             '//----------------------------------------------------
             if (lookUp < 0 or lookUp > ubound(aFilenames)) then 
                lookUp = 0
             end if
          else
             lookUp = 0
          end if
          %>
          
          <html>
          <body>
             <img src="<%= IMAGE_DIRECTORY %><%= aFilenames(lookUp) %>" />
             <br />
             <a href="?pic=<%= lookUp - 1 %>"><< Previous</a> &nbsp; <a href="?pic=<%= lookUp + 1 %>">Next >></a>
          
          </body>
          </html>

          Comment

          • Sonasang
            New Member
            • Sep 2007
            • 27

            #6
            Originally posted by Nicodemas
            It's a good solution, but he did say he wanted previous/next buttons.

            this should work, though, i did not test it.

            Code:
            <%
            '//----------------------------------------------------
            '// declare some constants and variables
            '//----------------------------------------------------
            dim oFileSystem, oFolder, nFile, i, aFilenames, lookUp
            
            i = 0
            const IMAGE_DIRECTORY = "/path_to_my_image_directory/"
            
            '//----------------------------------------------------
            '// set up FSO
            '//----------------------------------------------------
            set oFileSystem = server.createobject("scripting.filesystemobject")
            
            '//----------------------------------------------------
            '// get all images in image directory, store filenames
            '// in array
            '//----------------------------------------------------
            set oFolder = oFileSystem.getFolder(server.mappath(IMAGE_DIRECTORY))
            
            '//----------------------------------------------------
            '// resize array to fit number of files in directory
            '//----------------------------------------------------
            redim aFilenames(oFolder.files.count - 1)
            
            '//----------------------------------------------------
            '// loop through files in folder, assign each to
            '// index in array
            '//----------------------------------------------------
            for each nFile in oFolder.files
               aFilenames(i) = nFile.name
               i = i + 1
            next
            
            set oFolder = nothing
            set oFileSystem = nothing
            
            '//----------------------------------------------------
            '//determine which image the user wants to look at
            '//----------------------------------------------------
            if request.querystring("pic") <> "" and isnumber(request.querystring("pic")) then
               lookUp = cint(request.querystring("pic"))
               '//----------------------------------------------------
               '// make sure the value of lookUp doesn't break
               '// our array bounds
               '//----------------------------------------------------
               if (lookUp < 0 or lookUp > ubound(aFilenames)) then 
                  lookUp = 0
               end if
            else
               lookUp = 0
            end if
            %>
            
            <html>
            <body>
               <img src="<%= IMAGE_DIRECTORY %><%= aFilenames(lookUp) %>" />
               <br />
               <a href="?pic=<%= lookUp - 1 %>"><< Previous</a> &nbsp; <a href="?pic=<%= lookUp + 1 %>">Next >></a>
            
            </body>
            </html>



            Hi ,

            Thanks a lot for ur timely help .. I will check it and let u know...

            Thanks again

            Comment

            • Sonasang
              New Member
              • Sep 2007
              • 27

              #7
              Hi ,
              Its working well. Thanks a lot.

              Comment

              • Nicodemas
                Recognized Expert New Member
                • Nov 2007
                • 164

                #8
                You're welcome :D I am happy it worked out for you.

                Comment

                Working...