首先在服务器端先创建一个程序可以生成XML文件,以返回客户端,(getfolder.asp)
%
‘written by Linzhang Chen ,2003-4-20
‘ 转载请注明出处和保留此版权信息
response.write ?xml version=1.0 encoding=GB2312?chr
response.write mediafilechr
folders=request
if folders=/ then
folders=
end if
dim count
count=0
folders=replace
basefolder=../media/‘基准的文件夹路径
newfolder=basefolderfolders
Set fso =server.CreateObject
set f=fso.getfolder)
set sf=f.subfolders
for each fd in sf‘返回指定路径下面的文件夹列表
response.write filechr
response.write ftypefolder/ftypechr
response.write fnamefd.name/fnamechr
response.write /filechr
count=count+1
next
set sf=nothing
set ff=f.Files
for each fi in ff
fname=fi.name
if instr+1)))0 then‘设定允许返回的文件类型,防止源码泄露
response.write filechr
response.write ftypefile/ftypechr
response.write fnamefname/fnamechr
response.write /filechr
count=count+1
end if
next
‘如果该目录下没有文件,就发一个空元素
if count=0 then
response.write filechr
response.write ftypeempty/ftypechr
response.write fname0/fnamechr
response.write /filechr
end if
response.write /mediafile
set ff=nothing
set f=nothing
set fso=nothing
%
下面就是客户端的JS的功夫了
!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 Transitional//EN
HTML
HEAD
TITLE 选择视频文件 /TITLE
style
tdfont-size:9pt
selectwidth:210
.s2width:250
/style
SCRIPT LANGUAGE=javascript
!
/*written by Linzhang Chen ,2003-4-20
转载请注明出处和保留此版权信息 */
//预装载图片
var imgback = new Image;
imgback.src =
http://www.wzsky.net/html/article/asp/asp2/images/arrow.gif;