遍历文件夹下的图片文件,然后在页面滚动显示,怎么做呢?我不会asp麻烦大家给我代码

woaiwoaiyuyu 2007-09-06 02:26:53
遍历文件夹下的图片文件,然后在页面滚动显示,怎么做呢?我不会asp麻烦大家给我代码

刚找了一段

<%
Set fso = Server.CreateObject("Scripting.FileSystemObject")
on error resume next
Set objFolder=fso.GetFolder(server.MapPath("../path"))
Set objFiles=objFolder.Files
'循环输出文件夹path下的文件的文件名
For each objFile in objFiles
filelist = filelist&","&objFile.name
Next

'释放对象
Set objFolder=nothing
Set fso=nothing
%>

但是这个不能判断是不是图片文件

然后我 response.Write(filelist)

以后的结果是 ,ad.jpg,banner.swf,bar_01.gif,bg-1.gif

出来是出来了

但是页面如何取到,并滚动显示呢?

大家帮忙呀,好急呀T_T
...全文
1478 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
dnawo 2007-09-24
  • 打赏
  • 举报
回复
修改了下上边的代码,经测试可行:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
Dim fso,objFolder,objFiles
Dim filelist

Set fso = Server.CreateObject("Scripting.FileSystemObject")
'on error resume next
Set objFolder=fso.GetFolder(server.MapPath("."))
Set objFiles=objFolder.Files
'循环输出文件夹path下的文件的文件名
For each objFile in objFiles
If getExt(objFile.name)="gif" or getExt(objFile.name)="jpg" or getExt(objFile.name)="jpeg" Then
filelist = filelist&"<img src="""&objFile.name&""" width=""80"" height=""31""> "
End If
Next

'释放对象
Set objFolder=nothing
Set fso=nothing

'获取文件类型
Function getExt(str)
getExt = Lcase(Right(str,Len(str)-InstrRev(str,".")))
End Function
%>
<marquee direction="left" scrollamount="2" scrolldelay="120" width="200" height="32"><% =filelist %></marquee>
hunshihaichong 2007-09-23
  • 打赏
  • 举报
回复
我只是给这个代码补充页面滚动显示!

如果你有哪些不懂再问,结帐吧
cuidenghong123 2007-09-22
  • 打赏
  • 举报
回复
用数据库
haowawa2008 2007-09-21
  • 打赏
  • 举报
回复
直接放数据库不就可以了
woaiwoaiyuyu 2007-09-18
  • 打赏
  • 举报
回复
我晕,楼上的,你不是吧别人的复制了么。。。晕倒

hunshihaichong 2007-09-06
  • 打赏
  • 举报
回复
<%
Set fso = Server.CreateObject("Scripting.FileSystemObject")
on error resume next
Set objFolder=fso.GetFolder(server.MapPath("./pic/"))
Set objFiles=objFolder.Files
Response.Write "<marquee id=""affiche"" align=""left"" behavior=""scroll""

bgcolor=""#FFFFFF"" direction=""up"" height=""300"" width=""200"" hspace=""50""

vspace=""20"" loop=""-1"" scrollamount=""10"" scrolldelay=""200"" onMouseOut=""this.start

()"" onMouseOver=""this.stop()"">"
For each objFile in objFiles
TmpArr = Split(objFile.Name, ".")
ExtenName = TmpArr(Ubound(TmpArr))
If InStr(1, "|GIF|BMP|PNG|JPG|", "|" & ExtenName & "|", 1) > 0 Then
Response.Write "<img src=""./pic/" & objFile.Name & """>"&"<br>"
End If
Next
Response.Write "</marquee>"
'释放对象
Set objFolder=nothing
Set fso=nothing
%>
cnfreer 2007-09-06
  • 打赏
  • 举报
回复
<%
Set fso = Server.CreateObject("Scripting.FileSystemObject")
on error resume next
Set objFolder=fso.GetFolder(server.MapPath("../path"))
Set objFiles=objFolder.Files
Response.Write "<div style=""width: 300px;height: 200px;overflow: auto;"">"
For each objFile in objFiles
TmpArr = Split(objFile.Name, ".")
ExtenName = TmpArr(Ubound(TmpArr))
If InStr(1, "|GIF|BMP|PNG|JPG|", "|" & ExtenName & "|", 1) > 0 Then
Response.Write "<img src=""../path/" & objFile.Name & """>"
End If
Next
Response.Write "</div>"
'释放对象
Set objFolder=nothing
Set fso=nothing
%>
woaiwoaiyuyu 2007-09-06
  • 打赏
  • 举报
回复
现在我是想知道怎么根据文件名分类
比如张3的照片是01开头的

李4的是02开头的,区分这个。。。

phoenix2006 2007-09-06
  • 打赏
  • 举报
回复
很想帮你 可是我不会ASP 呵呵 我搞C/C++的
tantaiyizu 2007-09-06
  • 打赏
  • 举报
回复
fso

28,403

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧