Random Picture Display ASP code

Source: Internet
Author: User
Tags count servervariables domain
Random | show <% @LANGUAGE = "VBSCRIPT" codepage= "936"%>
<%
'----------------------------------------------------------------------------------------
' When forwarding, please keep this declaration information, this statement does not affect your display speed!
' ************************* random picture display ****************************
' Code design: Wild Man
' Use instance: img.asp?list= Picture Storage Directory
' Website: http://yjj.con.cn
' Disclaimer: Copyright No, use it at will! ^_^ But if you don't mind giving me a little connection, I would be grateful!
'----------------------------------------------------------------------------------------
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 "This page needs the correct parameter introduction, you are missing the related parameter!" The correct format is as follows: "&AllPath& img.asp?list= picture Storage Directory"
Response.End ()
End If

filename = Showfilelist ("./" &list& "/")
if filename = "NO" Then
Response.Write "The directory you specified <b>" &list& "</b> does not exist, please specify it again! "
Response.End ()
End If

if filename = "" Then
Response.Write "Your specified directory <b>" &list& "</b> no related picture files exist, please reassign! "
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)%>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.