调用本地文件夹下的图片

slysmart 2010-03-30 04:25:30
如果我的图片放在我的虚拟目录的imagin下
我该如何该这些代码,能显示文件下的图片
<%
response.write "<table><tr>"
Dim path,fso,objFolder,file,foldFiles
url = Request.ServerVariables("SERVER_NAME")
paths="temp"'图片文件所在的文件夹
path=server.MapPath(paths)
Set fso=Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = fso.GetFolder(path)
Set foldFiles = objFolder.files
i=1
For Each file In foldFiles
temp=split(file,"\")
files=temp(ubound(temp))
urls="http:/" &"/" &url &"/" &paths & "/" & files
response.write "<td><a href='"&urls&"'><img src='"&urls&"' width='100' /></td>"
if i mod 5 = 0 then response.write "</tr><tr>"
i=i+1
Next
Set objFolder=nothing
Set objSubFolders=nothing
Set foldFiles=nothing
Set fso=nothing
response.write "</table>"
%>

非常感谢。
...全文
144 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
slysmart 2010-03-30
  • 打赏
  • 举报
回复
非常感谢,OK了
孟子E章 2010-03-30
  • 打赏
  • 举报
回复
也可以这样,自动寻找虚拟目录的名字
<%

response.write "<table><tr>"
Dim path,fso,objFolder,file,foldFiles
url = Request.ServerVariables("PATH_INFO")
url = Mid(url,1,InStr(2,url,"/"))


paths="temp"'图片文件所在的文件夹
Set fso=Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = fso.GetFolder(Server.MapPath(paths))
Set foldFiles = objFolder.files
i=1
For Each file In foldFiles
temp=split(file,"\")
files=temp(ubound(temp))
urls=url &"/" &paths & "/" & files
response.write "<td><a href='"&urls&"'><img src='"&urls&"' width='100' /></td>"
if i mod 5 = 0 then response.write "</tr><tr>"
i=i+1
Next
Set objFolder=nothing
Set objSubFolders=nothing
Set foldFiles=nothing
Set fso=nothing
response.write "</table>"
%>
孟子E章 2010-03-30
  • 打赏
  • 举报
回复
假如虚拟目录名字为A

<%
response.write "<table><tr>"
Dim path,fso,objFolder,file,foldFiles
url = "/A/"
paths="temp"'图片文件所在的文件夹
Set fso=Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = fso.GetFolder(Server.MapPath(paths))
Set foldFiles = objFolder.files
i=1
For Each file In foldFiles
temp=split(file,"\")
files=temp(ubound(temp))
urls=url &"/" &paths & "/" & files
response.write "<td><a href='"&urls&"'><img src='"&urls&"' width='100' /></td>"
if i mod 5 = 0 then response.write "</tr><tr>"
i=i+1
Next
Set objFolder=nothing
Set objSubFolders=nothing
Set foldFiles=nothing
Set fso=nothing
response.write "</table>"
%>

28,391

社区成员

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

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