我正在尝试创建一个简单的网站,该网站将显示特定文件夹中每个图像的缩略图。这些文档将存储在Windows 7 Pro计算机上,并使用IIS托管。我没有运气能找到适合我的代码,所以我希望在这里找到帮助...
可以使用Javascript或VBScript轻松完成此操作吗?由于它是在IIS下运行的,我应该看看ASP来生成HTML输出吗?
图像存储在网站根目录下的名为“ images”的目录中。默认网页名为“ index.html”
我们非常感谢您的帮助。
答案 0 :(得分:0)
这是我的理想之选,虽然可以使用,但由于不使用缩略图,因此占用了大量带宽:
<!DOCTYPE html>
<html>
<head>
<title>Our Wedding - Photographer Photos</title>
</head>
<body>
<center><h1>Our Wedding - Photographer Photos</h1></center>
<%
page = request.querystring("page")
size=16
start = page * size
%>
<% ListFolderContents(Server.MapPath("./photographer")) %>
<%
sub ListFolderContents(path)
dim fs, folder, file, item, url
set fs = CreateObject("Scripting.FileSystemObject")
set folder = fs.GetFolder(path)
' Count number of files
total = 0
for each item in folder.Files
total = total + 1
next
Response.Write("<table>")
p = 0
c = 0
for each item in folder.Files
if ( p >= start ) then
if ( c mod 4 = 0 ) then Response.write("<tr>" & vbCrLf)
url = MapURL(item.path)
Response.Write("<td width=""20%""><a href=""" & url & """><img src=""" & url & """ width=""100%""></a></td>")
if ( c mod 4 = 3 ) then Response.write("</tr>" & vbCrLf)
c = c + 1
end if
p = p + 1
if ( c => size ) then Exit For
next
if (c mod 4 <> 0 ) then Response.write("</tr>" & vbCrLf)
Response.Write("</table>")
Response.Write("</br><center>")
if ( page >= 1 ) then Response.Write("<a href=""photographer.asp?page=" & page-1 & """><- BACK</a> ")
Response.Write("<a href=""index.html""> HOME </a>  ")
if ( p < total ) then Response.Write("<a href=""photographer.asp?page=" & page+1 & """>NEXT -></a>")
Response.Write("</center></br>")
end sub
function MapURL(path)
dim rootPath, url
'Convert a physical file path to a URL for hypertext links.
rootPath = Server.MapPath("/")
url = Right(path, Len(path) - Len(rootPath))
MapURL = Replace(url, "\", "/")
end function
%>
</body>
</html>