php用来获得一个文件夹下所有文件的文件名
点击次数:112 次 发布日期:2008-10-28 09:42:22 作者:源代码网
|
源代码网推荐
| 以下为引用的内容:
源代码网整理以下php:
源代码网整理以下<?php $dir = "/etc/php5/";
源代码网整理以下if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { echo "filename: $file : filetype: " . filetype($dir . $file) . "
"; } closedir($dh); } }
源代码网整理以下ASP:
源代码网整理以下<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> <% Dim thisPath,FSO,fileItem,allFolder thisPath = Server.MapPath(Request.ServerVariables("SCRIPT_NAME")) "得到ASP文件的路径 Set FSO = createobject("scripting.filesystemobject")"创建FSO对像 Set allFolder = FSO.GetFile(thisPath).parentfolder.files "得到ASP所在目录的父级对像,它就包括了这个ASP和这个文件夹下的其它文件。thisPath当然可以自定义。
源代码网整理以下"下面是生成xml文件:
源代码网整理以下Response.write("<?xml version=""1.0"" encoding=""utf-8""?>")"开始输出XML Response.ContentType = "text/XML" Response.Write("<path>") For Each fileItem In allFolder "遍历整个对像中的元素 If lcase(right(fileItem.name,4))=".jpg" Then "如果后缀是JPG,这是可以判断后缀。 Response.Write("<url>"+fileItem.name+"</url>")"就把它的文件名输出为XML的一个新节点 End If Next Response.Write("</path>") Response.End() %> "这是从blueidea-flash里学来的。呵呵。记录一下,防备忘记。
|
源代码网供稿. |