首页 » 建站技术 » 浏览内容

刷新一次图片变一次的代码[ASP]


2005-12-31 15:29:54 7,845 views 0 发表评论 字体: 作者:C.K.

From:http://www.xbulo.com/article.asp?id=3

把下面的代码保存为ASP文件

程序代码

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<% Function AllPath()
Dim Domain,GFilePath
Domain = Request.ServerVariables(“SERVER_NAME”)
GFilePath = Request.ServerVariables(“PATH_INFO”)
GFilePath = lcase(left(GFilePath,instrRev(GFilePath,”/”)))
AllPath = “http://”&Domain&GFilePath
End Function

Function ShowFileList(folderspec)
Dim Path,objFSO,objFolder,count,objFile,nume,S
Path = Server.MapPath(folderspec)
Set objFSO = Server.createObject(“Scripting.FileSystemObject”)
If objFSO.FolderExists(Path) Then
Set objFolder = objFSO.GetFolder(Path)
count = 0
For Each objFile in objFolder.Files
count = count+1
Next
randomize
nume = Int((count*rnd)+1)
S = 0
ShowFileList = “”
For Each objFile in objFolder.Files
S = S + 1
If S = nume Then
ShowFileList = objFile.Name
Exit For
End If
Next
Set objFolder = Nothing
Else
ShowFileList = “NO”
End If
Set objFSO = Nothing
End Function

Dim list,filename,address,str

list = trim(Request.QueryString(“list”))
if list = “” then
Response.write “本页需要正确参数引入,您缺少相关的参数!正确格式如下:”&AllPath&”img.asp?list=pics”
Response.End()
end if

filename = ShowFileList(“./”&list&”/”)
if filename = “NO” then
Response.write “您指定的目录“&list&”不存在,请重新指定!”
Response.End()
end if

if filename = “” then
Response.write “您指定的目录“&list&”没有相关的图片文件存在,请重新指定!”
Response.End()
end if

str = right(filename,3)
if str<>“jpg” and str<>“gif” then
filename = “erro.gif”
end if

address = AllPath&list&”/”
address = address&filename
%>
<%Response.redirect(address)%>

把上面的ASP文件和图片文件夹放在同一级目录下
比如:上面的文件名为 img.asp 放图片的文件夹为 pic
那么链接地址就是:http://www.***.com/img.asp?list=pic

评论 0 条回应 (访客:0 条, 博主:0 条) 发表

  1. 暂无评论,快抢沙发吧。

发表评论

  • 插入图像

要发表评论,您必须先登录