Print Page | Close Window

display images from folder

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=5124
Printed Date: 30 March 2026 at 6:12pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: display images from folder
Posted By: billbusch
Subject: display images from folder
Date Posted: 19 August 2003 at 12:14pm

I am trying to display all images contained in a folder (which will change over time).

I've tried a few things that have not worked - expert advice would be appreciated.

BillBusch

Bay Shore NY




Replies:
Posted By: FLATLINE
Date Posted: 19 August 2003 at 12:19pm

Some guy on this forum posted this code before, I wish I could remember his name ... oh well, here ya go!

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<script language="JavaScript">
  function confirm_delete(intSectionID)
   {
   if (confirm("Are you sure that you would like to delete this file?"))
    {
    document.location = "images.asp?Action=Delete&File=" + intSectionID ;
    }
   }
</script>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<%
ImagesPath = "images/"

If Request.QueryString("Action") = "Delete" Then
 Dim strImage
 
 strImage = ImagesPath & Request.QueryString("File")
 response.write(server.mappath(strImage))
 Set objFSO = CreateObject("Scripting.FileSystemObject")
 objFSO.DeleteFile(server.mappath(strImage))
 objFSO.Close
 Set objFSO = Nothing
End If
%>

<table border="0" cellpadding="0" cellspacing="0" width="400" align="center">
  <tr>
   <td align="left" width="10"><img src="../images/left.gif" width="8" height="20" border="0" alt=""></td>
   <td width="100%"  align="center">Image Management</td>
   <td align="right" width="10"><img src="../images/right.gif" width="8" height="20" border="0" alt=""></td>
  </tr>
  <tr>
   <td colspan="3" valign="top">
    <table border="0" width="100%" bgcolor="#000000" cellpadding="0" cellspacing="1" valign="top">
     <tr>
      <td bgcolor="#fffff0" valign="top">
       <table cellpadding="0" cellspacing="0" border="0" width="100%">
        <tr>
         <td>
          <table width="100%" border="0" align="left" cellpadding="3" cellspacing="0">
              <tr align="left" valign="top">
               <td width="155"><font class="Bold">File Name</font></td>
               <td width="55" align="center"><font class="Bold">Size</font></td>
               <td align="center"><font class="Bold">Date</font></td>
            <td align="center"><font class="Bold">Actions</font></td>
              </tr><%
              Dim objFSO 'File System Object
              Dim objFile 'File Object
              Dim objFolder 'Folder Object
              Set objFSO = CreateObject("Scripting.FileSystemObject") 'Create File System Object To Get list of files
              Set objFolder = objFSO.GetFolder(server.mappath(ImagesPath)) 'Set the object folder To the mapped path
              'For Each file In the folder
              For Each objFile In objFolder.Files
            if objFile.Name <>  "blank.gif" then %>
               <tr align="left" valign="top">
                <td>
             <b><%=objFile.Name%></b><br>
             <% response.write "<img src='" & ImagesPath & objfile.name & "'>" %>
             <hr>
             </td><td><%
                 'We will format the file size so it looks pretty
                 if objFile.Size <1024 Then
                  Response.Write objFile.Size & " Bytes"
                 ElseIf objFile.Size < 1048576 Then
                  Response.Write Round(objFile.Size / 1024.1) & " KB"
                 Else
                  Response.Write Round((objFile.Size/1024)/1024.1) & " MB"
                 End if %>
                </td>
                <td><%=objFile.DateLastModified%></td>
             <td align="center">[<a href="javascript:confirm_delete('<%=objFile.Name%>')">Del</a>]</td>
               </tr><%
            end if
              Next %>
             </table>
         </td>
        </tr>
       </table>
      </td>
     </tr>
    </table>
   </td>
  </tr>
 </table>
</body>
</html>



-------------
Visit my site: http://darkgreen.service-club.net - DarkGreen HQ


Posted By: billbusch
Date Posted: 19 August 2003 at 12:39pm

Thanks - works like a charm

Bill Busch




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net