显示目录中图片错误
<% Dim fso,objFolder,objFiles
Dim filelist
Set fso=Server.CreateObject("Scripting.FileSystemObject")
'on error resume next
Set objFolder=fso.GetFolder(server.MapPath("pic/"))
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&""" alt="""&objFile.name&""" width=""250"" height=""300"" > "
'filelist = filelist&" <img src="""&objFile.name&""" width=""1000"" height=""960"" > "
End If
Next
'释放对象
Set objFolder=nothing
Set fso=nothing
'获取文件类型
Function getExt(str)
getExt = Lcase(Right(str,Len(str)-InstrRev(str,".")))
End Function
%>
<%
'输出图片
%>
<%
源代码也是网上找的,功能是显示某个目录中的全部图片。如果图片放在网页同级目录下则正常,如果把图片放到其下的一个目录中,如“PIC”目录,则图片张数和名称都符合,错误是:在网页中显示的图片全是红叉叉,看网页图片属性为:“http://*/1/1245795.jpg”,实际上图片全在“1/PIC”目录中,请帮我查查错在哪!
Dim filelist
Set fso=Server.CreateObject("Scripting.FileSystemObject")
'on error resume next
Set objFolder=fso.GetFolder(server.MapPath("pic/"))
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&""" alt="""&objFile.name&""" width=""250"" height=""300"" > "
'filelist = filelist&" <img src="""&objFile.name&""" width=""1000"" height=""960"" > "
End If
Next
'释放对象
Set objFolder=nothing
Set fso=nothing
'获取文件类型
Function getExt(str)
getExt = Lcase(Right(str,Len(str)-InstrRev(str,".")))
End Function
%>
<%
'输出图片
%>
<%