- <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
& N# r/ L4 s, A; s - <%
- F. ?! _2 v5 [; j - Function AllPath() N2 [% n8 m w( _
- Dim Domain,GFilePath " b5 S- w6 ?( d, p& ~( W
- Domain = Request.ServerVariables("SERVER_NAME") ' T D7 R# y( Y5 A' m4 x9 c
- GFilePath = Request.ServerVariables("PATH_INFO") " s+ F% x& L2 H: X7 B
- GFilePath = lcase(left(GFilePath,instrRev(GFilePath,"/")))
3 H2 Y+ b7 _' [% [* H, I9 Z5 | - AllPath = "http://www.w16888.com/" //唯一需要修改的地方,你的圖片目錄如果是在http://xxxx/myfile/angie/pic,這裡就寫http://xxx.com/myfile/angie/ ; ( C( f5 ?& ]' w" }# K' y
- End Function
0 I6 P+ C) d4 {1 S; q. c6 ^ m6 M - Function ShowFileList(folderspec) 3 Q: E# P/ D" z2 }
- Dim Path,objFSO,objFolder,count,objFile,nume,S ( p; @7 ~0 O5 a' P9 ]' a/ }
- Path = Server.MapPath(folderspec) 3 Y2 |+ }( v1 S: s# l! F$ d
- Set objFSO = Server.CreateObject("Scripting.FileSystemObject") ( T: w& m1 ^- r" z8 v( I- Y2 ?
- If objFSO.FolderExists(Path) Then
, u7 p8 _" L* u8 \6 G( `+ K1 |* s - Set objFolder = objFSO.GetFolder(Path)
+ B- w2 \( T, w6 r, a N - count = 0
, m, h' e* Z; n- @ - For Each objFile in objFolder.Files 4 s4 W+ K- w5 g5 D3 H" W
- count = count+1 & M7 M- H' p; N; B. t; N0 K1 n
- Next
% V2 @9 U1 @0 b, P$ |+ W3 c8 T - randomize 5 u$ N& b0 f) d) j' N/ H
- nume = Int((count*rnd)+1) R8 J4 G- @8 e% K+ m+ ^/ ^, o
- S = 0 6 v8 x3 I4 H, k+ i
- ShowFileList = ""
/ C7 B4 ^3 q! p) L% k: N - For Each objFile in objFolder.Files
$ l6 d& Y& [; F. e - S = S + 1 - R& U0 K9 d+ V% u
- If S = nume Then ' c" _' y2 t- h9 v
- ShowFileList = objFile.Name ( l# {: H. m4 i8 i
- Exit For % J5 J* {8 h' e# m9 z4 V8 L0 y
- End If
x7 M/ {" z- m - Next
* ~2 e. l3 A( P/ f! { - Set objFolder = Nothing & ]& A7 O9 g$ x
- Else
) ^: g) q: ?8 {; O+ k - ShowFileList = "NO" ( h6 L2 m+ B- D) b6 S5 i$ _7 t# L2 t
- End If
& Y$ ~* S" a# L- {' y6 M* W' j: N - Set objFSO = Nothing
5 L4 T: c7 Q/ G5 E+ j - End Function ! b# A r3 o2 { y
- Dim list,filename,address,str
' B, \# B% j: s& U9 f" @ - list = trim(Request.QueryString("list"))
8 u' [) B. g6 e/ F5 Y2 c - if list = "" then & y' m) {3 J. M: w: l( j* X
- Response.write "本頁需要正確參數引入,您缺少相關的參數!正確格式如下:"&AllPath&"xxxxxx.asp?list=xxxxxx.jpg"
* R# Z* k6 X) V" i" r# m5 G7 ] - Response.End()
( J5 N% M+ e4 m0 H - end if
% I0 N4 u4 I2 G, ^ Y" ^$ z6 B& m - filename = ShowFileList("./"&list&"/")
1 |0 N7 U8 @' O0 q - if filename = "NO" then 3 a. Q2 ?; u2 y: p* n
- Response.write "您指定的目錄<b>"&list&"</b>不存在,請重新指定!" ! |3 |$ |) U- t& g4 t! \4 l
- Response.End()
) s6 b3 q: U3 v! @) l: _ - end if & h, r8 o; F. Y8 U, E* s/ I, N
- if filename = "" then
! w3 ]/ n3 s5 O) V' P - Response.write "您指定的目錄<b>"&list&"</b>沒有相關的圖片文件存在,請重新指定!" % X/ |! X& b; [3 z! d, k
- Response.End() , |+ `4 v2 O$ z) Z) c8 \, L
- end if
6 L6 g* Q3 v$ @" p- [ - str = right(filename,3)
' G5 b1 f! j9 r9 u D1 ^+ _ - if str<>"jpg" and str<>"gif" then
; ~" n2 T* W% {" A: A - filename = "erro.gif"
" @) g7 u! J; P! u; T - end if % W. ?* f8 j: B$ ^
- address = AllPath&list&"/"
6 M3 w: w" h! i* L5 X2 t - address = address&filename
7 L2 x# a" w) V$ L - %> / D- |' M" k, x& C: b3 u
- <%Response.redirect(address)%>
7 w, E c- P9 Y3 a7 R! e# a - 把這段代碼保存為im.asp' }, l# q! D; q5 ^$ [, P4 q
- 把美女圖片放在pic文件夾下,把pic文件夾和im.asp放在網站根目錄下,在瀏覽器裡打開演
複製代碼
5 o! W7 f# r% O% ~[ 本帖最後由 tcbxh2008 於 2007-6-3 16:47 編輯 ] |
|