<%
latestfolder = "na"
latestdate = cdate("01/01/09")
set fs=Server.CreateObject("Scripting.FileSystemObject")
set fo=fs.GetFolder(Server.MapPath("images/gallery"))
for each folder in fo.subfolders
if cdate(folder.DateLastModified) > latestdate then
latestdate = cdate(folder.DateLastModified)
latestfolder = folder.name
end if
next
if latestfolder <> "na" then
set fi=fs.GetFolder(Server.MapPath("images/gallery/" & latestfolder))
looptimes = 0
for each file in fi.files
if month(file.DateLastModified) = month(latestdate) then
if right(lcase(file.Name),3) = "jpg" then %>
<a href="thumbnail.aspx?picture=<%=server.URLEncode("images/gallery/" & latestfolder & "/" & file.Name)%>&maxWidth=640&maxHeight=480" target="_blank" style="text-decoration:none; cursor:pointer;">
<img src="thumbnail.aspx?picture=<%=server.URLEncode("images/gallery/" & latestfolder & "/" & file.Name)%>&maxWidth=100&maxHeight=60" style="border:1px solid #ffffff; margin:5px; margin-top:14px;">
</a>
<% end if
end if
looptimes = looptimes + 1
if looptimes = 6 then exit for end if
next
end if
%>
希望有些人可以帮助我:)。
答案 0 :(得分:1)
以下代码看起来正在拾取当月的所有JPEG文件:
if month(file.DateLastModified) = month(latestdate) then
if right(lcase(file.Name),3) = "jpg" then%>
...
<% end if
end if
答案 1 :(得分:0)
当它循环遍历文件时,它会检查图像的上次修改日期是否与文件夹的上次修改日期相匹配。这是该专辑的“几张最新照片”的原始编码器定义。它还确保永远不会超过6个。
如果您不经常上传照片,则每次只能拍摄一张照片。如果你根本没有得到任何照片,你可能在该文件夹中做了其他的事情,这将改变其上次修改日期,而不添加任何照片。
我会考虑摆脱月份标准,并坚持使用6张照片限制,即替换
if month(file.DateLastModified) = month(latestdate) then
if right(lcase(file.Name),3) = "jpg" then %>
<a href="thumbnail.aspx?picture=<%=server.URLEncode("images/gallery/" & latestfolder & "/" & file.Name)%>&maxWidth=640&maxHeight=480" target="_blank" style="text-decoration:none; cursor:pointer;">
<img src="thumbnail.aspx?picture=<%=server.URLEncode("images/gallery/" & latestfolder & "/" & file.Name)%>&maxWidth=100&maxHeight=60" style="border:1px solid #ffffff; margin:5px; margin-top:14px;">
</a>
<% end if
end if
与
if right(lcase(file.Name),3) = "jpg" then %>
<a href="thumbnail.aspx?picture=<%=server.URLEncode("images/gallery/" & latestfolder & "/" & file.Name)%>&maxWidth=640&maxHeight=480" target="_blank" style="text-decoration:none; cursor:pointer;">
<img src="thumbnail.aspx?picture=<%=server.URLEncode("images/gallery/" & latestfolder & "/" & file.Name)%>&maxWidth=100&maxHeight=60" style="border:1px solid #ffffff; margin:5px; margin-top:14px;">
</a>
<% end if