- <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%> 7 N8 L1 [2 l, [* g* J' R, H
- <%
5 x) m4 g4 W+ l( Y5 T' w2 g - Function AllPath() 3 I' E- W5 ^4 Z5 H$ ] {
- Dim Domain,GFilePath 1 n {9 W4 {( @! Z# I' c P$ Q7 z! e
- Domain = Request.ServerVariables("SERVER_NAME") ( w. X$ p7 _3 L$ i0 L+ n
- GFilePath = Request.ServerVariables("PATH_INFO")
. s+ ?' r- s+ e3 c2 [7 t - GFilePath = lcase(left(GFilePath,instrRev(GFilePath,"/")))
, F2 x3 g+ Z7 q& ~% u b4 [ - AllPath = "http://www.w16888.com/" //唯一需要修改的地方,你的圖片目錄如果是在http://xxxx/myfile/angie/pic,這裡就寫http://xxx.com/myfile/angie/ ; , f- N/ C" l# u9 U5 @6 f
- End Function 4 ^* k2 o K4 b' T: x! \& s+ O6 C/ i5 V
- Function ShowFileList(folderspec) ! i; _$ C) t6 b8 f
- Dim Path,objFSO,objFolder,count,objFile,nume,S
2 y' g* f$ @9 |; s% g) e" s( e( O1 B - Path = Server.MapPath(folderspec) 6 h" `2 R4 q2 o4 N
- Set objFSO = Server.CreateObject("Scripting.FileSystemObject") 2 X% }( e! P, r, S# ^1 ]
- If objFSO.FolderExists(Path) Then ) [# Q% M- n- O' C7 n% T- r/ @# q
- Set objFolder = objFSO.GetFolder(Path) 9 x! q1 w/ t% \; b: w
- count = 0 0 @: C1 J [* i6 e0 F# Z |7 Z
- For Each objFile in objFolder.Files 1 L3 e0 O" W- A2 \
- count = count+1 ! W0 Z& Y- h# f8 G2 |3 g
- Next
6 a7 {8 D- K% T: E J; Z - randomize ; m1 z; r: ~) G! S
- nume = Int((count*rnd)+1)
, M% i8 q0 K% O' R9 |2 D' E& Y - S = 0
6 d$ y- r- ~7 R - ShowFileList = "" 7 l, t+ g/ u" ?! o
- For Each objFile in objFolder.Files + ~0 W) r& q( D7 b y
- S = S + 1 g; L" J& K) E; c# C3 \6 D
- If S = nume Then 3 u2 P# P2 l4 Y
- ShowFileList = objFile.Name
4 }2 U8 z7 e/ `2 K - Exit For M1 w3 k! ]; C9 @0 m
- End If
1 Q( ]( q5 M4 ^" U; @# d - Next A/ I. I# h L
- Set objFolder = Nothing
L6 }2 E2 k9 b' d$ B' p5 a - Else ' Q* P$ n5 w8 G
- ShowFileList = "NO"
6 f# C8 T. s* ?" U# L3 J$ r$ a - End If
! O# ?7 M8 _/ y5 J u - Set objFSO = Nothing
5 X/ j X- X" R' ], I - End Function 2 M; F$ N4 Z: ~8 d1 P
- Dim list,filename,address,str % s* D' \: b' g$ B; b$ n# W4 W
- list = trim(Request.QueryString("list")) ' U" p4 ]% s" h) n
- if list = "" then
5 H& l- p0 Q a+ T- L! T - Response.write "本頁需要正確參數引入,您缺少相關的參數!正確格式如下:"&AllPath&"xxxxxx.asp?list=xxxxxx.jpg"
$ q: d5 G! A7 A, F5 U# D - Response.End()
7 ]9 j& T* Q T - end if $ @6 l+ g0 G, E0 S6 q+ G9 i" c: x$ o
- filename = ShowFileList("./"&list&"/") 4 X* I7 P7 W' \# u
- if filename = "NO" then
2 Z" o& J! W" A: I* ^ - Response.write "您指定的目錄<b>"&list&"</b>不存在,請重新指定!" % F/ N3 p2 T# i
- Response.End() * x/ Z) m: ?, A% f* U& Z ^2 _0 m
- end if " e2 W7 G3 r- U4 c Y
- if filename = "" then 1 l( Z1 ?6 j1 E
- Response.write "您指定的目錄<b>"&list&"</b>沒有相關的圖片文件存在,請重新指定!"
6 k$ a7 a) {0 n$ P4 n - Response.End() % j! W5 O J& u3 \- [* \
- end if 4 | @- n1 U; S% O+ b
- str = right(filename,3) 2 y; j# Z5 ~; J& t8 l. C
- if str<>"jpg" and str<>"gif" then 4 X: R' p/ Q# I; n3 i( [# i/ o
- filename = "erro.gif"
& t& k2 Z z- ^" j: t+ N - end if
Z/ R9 v# F. i! ]9 ?3 N. j8 a - address = AllPath&list&"/"
* b: h5 m: Q7 s/ ^1 a - address = address&filename
1 k% B1 E% ~4 S0 l8 z5 _! h - %> % N9 I% v& m" x$ F
- <%Response.redirect(address)%> . s1 U5 Y6 A4 c. @
- 把這段代碼保存為im.asp! J( l) P/ I+ z1 Y R
- 把美女圖片放在pic文件夾下,把pic文件夾和im.asp放在網站根目錄下,在瀏覽器裡打開演
複製代碼 " H% R% ]) r3 n+ g! |) ]+ J( ?' K
[ 本帖最後由 tcbxh2008 於 2007-6-3 16:47 編輯 ] |
|