|
|
| Author |
Message |
G-Bomb
Joined: 29 Feb 2004 Posts: 73
|
Posted: Sun Feb 29, 2004 7:26 pm Post subject: Automatic Image Page with many features. (ASP) |
|
|
These two file scripts will create an automatic picture page with many features. For this to work, you will be able to use the FileSystemObject in ASP, as well as the menubar I have posted HERE.
To begin this, you must have a folder off the root called Pictures. Then, put all of the different categories of pictures in different folders inside the Pictures folder. Name each categorial folder using underscores ( _ ) instead of spaces.
This script will then search out all of these folders and the pictures in each of those folders corresponding to your choice in the menubar, and display thumbnails of each of these pictures. Upon clicking those thumbnails, a seperate window will open showing a full-size image of your selection.
Last edited by G-Bomb on Sun Feb 29, 2004 7:35 pm; edited 1 time in total |
|
| Back to top |
|
 |
G-Bomb
Joined: 29 Feb 2004 Posts: 73
|
Posted: Sun Feb 29, 2004 7:30 pm Post subject: |
|
|
Now, create this file using any name you wish:
| Code: |
<%@ LANGUAGE="VBSCRIPT" %>
<HTML>
<HEAD>
<%
Sub OpenFSO()
Set fso = Server.CreateObject("Scripting.FileSystemObject")
End Sub
Sub CloseFSO()
Set fso = Nothing
End Sub
%>
<TITLE>Photo Album</TITLE>
</HEAD>
<BODY><CENTER>
<%
f = Request.Form("f")
Dim fso
Dim theRoot
Dim FoldersArray(10)
Dim title(10)
Call OpenFSO
Set picFolder = fso.GetFolder(Server.MapPath("Pictures"))
Set theFolders = picFolder.SubFolders
i = 0
For Each aFolder In theFolders
i = i + 1
FoldersArray(i) = aFolder.Name
title(i) = Replace(FoldersArray(i), "_", " ")
Next
Set theFolders = Nothing
Set picFolder = Nothing
Set theRoot = Nothing
Call CloseFSO
%>
<P STYLE="text-align:right;">
<FORM NAME="frmPictures" ACTION="#" METHOD="post">
<SELECT NAME="f" SIZE="1" onChange="if(this.options[this.selectedIndex].value != ''){ forms['frmPictures'].submit() }">
<OPTION VALUE="">View Pictures From:</OPTION>
<%
For i = 1 To UBound(title)
%>
<OPTION VALUE="<%= i %>"><%= title(i) %></OPTION>
<%
Next
%>
</SELECT>
</FORM>
</P>
<H4>Photo Album</H4>
<P>Click on an image to view it at full size in a separate window.
<BR>(Note: May take a few moments to load.)</P>
<%
If f <> "" Then
Response.Write "<H3>" & title(f) & "</H3>"
Call OpenFSO
Set theFolder = fso.GetFolder(Server.MapPath("Pictures/" & FoldersArray(f)))
Set theFiles = theFolder.Files
n = 1
For Each pic in theFiles
Response.Write "<A HREF='showpic.asp?f=" & FoldersArray(f) & "&p=" & pic.Name & "' TARGET='_blank'>"
Response.Write "<IMG SRC='Pictures/" & FoldersArray(f) & "/" & pic.Name & "' width='50' height='50'></A>"
n = n + 1
If n > 13 Then
Response.Write "<BR>"
n = 1
End If
Next
Set theFiles = Nothing
Set theFolder = Nothing
Call CloseFSO
End If
%>
</CENTER>
</BODY>
</HTML>
|
|
|
| Back to top |
|
 |
G-Bomb
Joined: 29 Feb 2004 Posts: 73
|
Posted: Sun Feb 29, 2004 7:31 pm Post subject: |
|
|
Finally create this file in the same folder as the one you just created. Call it "showpic.asp":
| Code: |
<%@ LANGUAGE="VBSCRIPT" %>
<HTML>
<HEAD>
<TITLE>Full-Size Picture</TITLE>
</HEAD>
<BODY>
<%
folder = Request.QueryString("f")
pic = Request.QueryString("p")
Response.Write "<IMG SRC='Pictures/" & folder & "/" & pic & "'>"
%>
</BODY>
</HTML>
|
|
|
| Back to top |
|
 |
|