首先在服务器端先创建一个程序可以生成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) response.write ""&chr(13) end if response.write "" set ff=nothing set f=nothing set fso=nothing %> 下面就是客户端的JS的功夫了(selectfile.asp) 选择视频文件 查找范围(I): 文件类型(T): 里面还有一个小文件blank.htm用来定义文件和文件夹显示的样式 New Document 调用的时候用以下函数,就可以实现以假乱真的服务器端选择文件的效果 function selectfile() { var arr = showModalDialog("selectfile.asp?temp="+Math.random(), "", "dialogWidth:453px; dialogHeight:252px; status:0;help:1"); if (arr != null) { return arr } } 该函数最后返回的是选中的文件名,函数里面所使用的几张图片大家就自已从文件选择框上抓了:) 估计在使用过程中可能还会遇到各种未知的BUG欢迎大家和我来交流:E_mail:clzwin@sina.com
http://www.bkjia.com/PHPjc/532141.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/532141.htmlTechArticle首先在服务器端先创建一个程序可以生成XML文件,以返回客户端,(getfolder.asp) quot; quot;folder) if folders=/ then folders= end if dim count count=0 fo...