最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
用XML+FSO+JS实现服务器端文件
时间:2022-07-02 10:24:58 编辑:袖梨 来源:一聚教程网
首先在服务器端先创建一个程序可以生成XML文件,以返回客户端,(getfolder.asp)
<%
'written by Linzhang Chen ,2003-4-20
' 转载请注明出处和保留此版权信息
response.write ""&chr(13)
response.write ""&chr(13)
folders=request("folder")
if folders="/" then
folders=""
end if
dim count
count=0
folders=replace(folders,"..","")
basefolder="../media/"'基准的文件夹路径
newfolder=basefolder&folders
Set fso =server.CreateObject("Scripting.FileSystemObject")
set f=fso.getfolder(server.mappath(newfolder))
set sf=f.subfolders
for each fd in sf'返回指定路径下面的文件夹列表
response.write ""&chr(13)
response.write "folder "&chr(13)
response.write ""&fd.name&" "&chr(13)
response.write " "&chr(13)
count=count+1
next
set sf=nothing
set ff=f.Files
for each fi in ff
fname=fi.name
if instr("asf,wma,wmv",lcase(mid(fname,instrrev(fname,".")+1)))>0 then'设定允许返回的文件类型,防止源码泄露
response.write ""&chr(13)
response.write "file "&chr(13)
response.write ""&fname&" "&chr(13)
response.write " "&chr(13)
count=count+1
end if
next
'如果该目录下没有文件,就发一个空元素
if count=0 then
response.write ""&chr(13)
response.write "empty "&chr(13)
response.write "0 "&chr(13)
<%
'written by Linzhang Chen ,2003-4-20
' 转载请注明出处和保留此版权信息
response.write ""&chr(13)
response.write "
folders=request("folder")
if folders="/" then
folders=""
end if
dim count
count=0
folders=replace(folders,"..","")
basefolder="../media/"'基准的文件夹路径
newfolder=basefolder&folders
Set fso =server.CreateObject("Scripting.FileSystemObject")
set f=fso.getfolder(server.mappath(newfolder))
set sf=f.subfolders
for each fd in sf'返回指定路径下面的文件夹列表
response.write "
response.write "
response.write "
response.write "
count=count+1
next
set sf=nothing
set ff=f.Files
for each fi in ff
fname=fi.name
if instr("asf,wma,wmv",lcase(mid(fname,instrrev(fname,".")+1)))>0 then'设定允许返回的文件类型,防止源码泄露
response.write "
response.write "
response.write "
response.write "
count=count+1
end if
next
'如果该目录下没有文件,就发一个空元素
if count=0 then
response.write "
response.write "
response.write "
相关文章
- 王者荣耀侦探能力大测试攻略 王者荣耀侦探能力大测试怎么过 11-22
- 无期迷途主线前瞻兑换码是什么 11-22
- 原神欧洛伦怎么培养 11-22
- 炉石传说网易云音乐联动怎么玩 11-22
- 永劫无间手游确幸转盘怎么样 11-22
- 无期迷途主线前瞻兑换码是什么 无期迷途主线前瞻直播兑换码介绍 11-22