|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
asp,你就只能等着微软给你解决,它不乐意你就只好悲催。而且asp跑在windows服务器上,windows服务器跟linux比起来简直弱爆了!dhtmlTutorials&CodeSnips:Graphics&Charts:Images
ThisASPScriptrecursesthroughadirectorytreeandloadsimagesintoaDHTMLpreloader.
Firstoff,bigthankstoBrianfromScriptAsylumforlettingmeusehisDHTMLsitepreloader.This
versionwillbeevenlesswork,becauseallyoudoistelltheASPtodrilldownthroughadirectory
structurelookingforimages,anditwillplacealltheimagenamesintoanarray,andoffitgoes.
Thesetupforthisisincrediblysimple.Firstoff,openPreloader.asp,andchangethefollowingvariables:
-boolRecurse:Tellthescripttodrilldownthroughsubdirectorieswithinthefolderyouchoose
(True/False)
-strVirtualRoot:Thefolderthatcontainsalltheimages
<%
boolRecurse=TrueRecursethroughsubdirectories?True/False
strVirtualRoot="../../Images"Directory
strRootFolder=Server.MapPath(strVirtualRoot)Grabthedirectory
intSize=0
SetobjFSO=Server.CreateObject("Scripting.FileSystemObject")
SetobjFolder=objFSO.GetFolder(strRootFolder)
strOutput=TraverseFolder(objFolder,strVirtualRoot,boolRecurse)
strOutput=mid(strOutput,1,Len(strOutput)-2)
SetobjFSO=Nothing
SetobjFolder=Nothing
FunctionTraverseFolder(objFolder,strVirtualRoot,boolRecurse)
strOutput=""
arrImages=Array("gif","jpg","png","jpeg")
OnlyprocessdirectoriesthatdoNOTstartwith
anunderscore.
IfNotLeft(objFolder.Name,1)="_"then
DimobjFile,strPath,strFileName,strFileSize,strExtension
Iteratethrougheachfileinthefolder
ForEachobjFileinobjFolder.Files
Obtaintheextensionofthecurrentfile
strPath=objFile.Path
strFileName=objFile.Name
intFileSize=objFile.Size
strExtension=Ucase(Right(strPath,Len(strPath)-InStrRev(strPath,".")))
Seeiffileisanimage
Forx=LBound(arrImages)toUBound(arrImages)
IfstrExtension=Ucase(arrImages(x))then
strOutput=strOutput&""&strVirtualRoot&"/"&strFileName&","
intSize=intSize+intFileSize
EndIf
Next
Next
IfboolRecursethen
Recursethroughthefolderssubdirectories
ForEachobjSubFolderinobjFolder.SubFolders
strOutput=strOutput&TraverseFolder(objSubFolder,strVirtualRoot&"/"&
objSubFolder.Name,boolRecurse)
Next
EndIf
Traverse</p>想法是和程序员的想法不一样的.至于为什么.大家去想一想.跟心理学有关的 |
|