This is what I use!
The code calls a folder on the server and basically displays everything in the directory... To test it, Name this code IMGVIEW.asp
Place it in a folder in the root called TEST
( C:/InetPub/wwwRoot/TEST)
Inside the "Test" folder on your root, create a folder called "IMAGES" (EG: C:\InetPub\wwwRoot\Test\Images )and put a few pictures in there... Open your browser,
http://yourcomputername/Test/ImgView.asp
You don not need to change ANY of the code if you follow those instructions!
Good Luck!
<%@ Language=VBScript %>
<% Option Explicit %>
<%
Const ImageFilePath = "images"
Const DeleteButtonLabel = "Delete Selected Images"
Dim objFSO
Dim objFolder
Dim objFile
'10
Dim strFileName
Dim strFileExtension
Dim blnShowImages
'15
If Request.QueryString("ShowImages") = "" Then
blnShowImages = True
Else
blnShowImages = CBool(Request.QueryString("ShowImages"))
End If
'21
If Request.Form("btnDelete") = DeleteButtonLabel Then
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
For Each strFileName In Request.Form("delete")
objFSO.DeleteFile(Server.MapPath(ImageFilePath & "/" & strFileName))
Next ' strFileName
Set objFSO = Nothing
End If
%>
<html>
<head>
<title>Image Browser</title>
</head>
<body>
<form action="<%= Request.ServerVariables("URL") %>" method="post">
<table border="1">
<tr><B>Please Note</B><BR> Once you choose to delete a selected item you cannot change it!<BR>Be careful with this... it doesn't ask "Are you sure?" and it doesn't offer any undelete capability so before you click on the button to delete selected items make sure those check marks are in the right places!
<th>Image Name</th>
<th>Image <a href="<%= Request.ServerVariables("URL") %>?ShowImages=<%= Not blnShowImages %>">(Toggle Display)</a></th>
<th>Delete This Image</th>
</tr>
<%
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(Server.MapPath("\images"))
'49
For Each objFile In objFolder.Files
strFileExtension = LCase(Mid(objFile.Name, InStrRev(objFile.Name, ".", -1, 1) + 1))
'If strFileExtension = "gif" Or strFileExtension = "jpg" Or strFileExtension = "jpeg" Then
' Original image file identification option:
'If objFile.Type = "GIF Image" Or objFile.Type = "JPEG Image" Then
%>
<tr>
<td>
<a href="<%= ImageFilePath & "/" & objFile.Name %>"><%= objFile.Name %></a>
</td>
<%
If blnShowImages Then
%>
<td>
<img src="<%= ImageFilePath & "/" & objFile.Name %>" />
</td>
<%
Else
%>
<td>
<a href="<%= ImageFilePath & "/" & objFile.Name %>">View File</a>
</td>
<%
End If
%>
<td align="center">
<input type="checkbox" name="delete" value="<%= objFile.Name %>" />
</td>
<%
'80
'End If
Next ' objFile
Set objFolder = Nothing
Set objFSO = Nothing
%>
<tr>
<td colspan="3" align="right">
<input type="submit" name="btnDelete" value="<%= DeleteButtonLabel %>">
</td>
</tr>
</table>
</form>
</body>
</html>