Asp显示某文件夹下图片的程序

来源:互联网 发布:linux 静态ip 网关 编辑:程序博客网 时间:2024/04/30 07:41

<%
Dim FolderName,Title

'Title为名称

FolderName为文件夹名称。

FolderName="Pictrue"
Title="图片List"

TruePath=server.MapPath(".")&"/"&FolderName
Response.Write TruePath
%>
<h1><font color=red><%=Title%></font></h1><br>
<table width="100%" border="0" cellspacing="0" cellpadding="0">


<%
'------------------------------------------------显示当前目录下的子目录和文件
Dim fso, f, f1, fc, s
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(TruePath)
set fs=f.SubFolders
Set fc =f.Files
i=1
For Each f1 in fc
dim filename
filename=f1.name
IF i=1 THen
%>
<tr>
<%
End IF
%>
<td align="center"><a href="<%=Replace(p2v_path(f1),"small","Big")%>" target="_blank"><Img border="0" width="200" src="<%=p2v_path(f1)%>"></a></td>
<%
If i=4 Then
i=0
%>
<%
End IF
i=i+1
Next

set fso=nothing
%>

</table>
<%
'-----------------------------------------------将文件路径转为www发布的路径这样就可以下载了
function p2v_path(p_path)
'p_path为硬盘上的物理路径
dim host
host=lcase(server.MapPath("/"))
p_path=lcase(p_path)
p2v_path=replace(p_path,host,const_domain_name)
end function
%>

 

注意:FolderName必须在此程序下。

原创粉丝点击