无为清净楼资源网 Design By www.qnjia.com
首先在服务器端先创建一个程序可以生成XML文件,以返回客户端,(getfolder.asp)
<%
'written by Linzhang Chen ,2003-4-20
' 转载请注明出处和保留此版权信息
response.write "<?xml version=""1.0"" encoding=""GB2312""?>"&chr(13)
response.write "<mediafile>"&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 "<file>"&chr(13)
response.write "<ftype>folder</ftype>"&chr(13)
response.write "<fname>"&fd.name&"</fname>"&chr(13)
response.write "</file>"&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 "<file>"&chr(13)
response.write "<ftype>file</ftype>"&chr(13)
response.write "<fname>"&fname&"</fname>"&chr(13)
response.write "</file>"&chr(13)
count=count+1
end if
next
'如果该目录下没有文件,就发一个空元素
if count=0 then
response.write "<file>"&chr(13)
response.write "<ftype>empty</ftype>"&chr(13)
response.write "<fname>0</fname>"&chr(13)
response.write "</file>"&chr(13)
end if
response.write "</mediafile>"
set ff=nothing
set f=nothing
set fso=nothing
%>
下面就是客户端的JS的功夫了(selectfile.asp)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> 选择视频文件 </TITLE>
<style>
td{font-size:9pt}
select{width:210}
.s2{width:250}
</style>
<SCRIPT LANGUAGE="javascript">
<!--
/*written by Linzhang Chen ,2003-4-20
转载请注明出处和保留此版权信息 */
//预装载图片
var imgback = new Image();
imgback.src = "images/arrow.gif";
var imgbackgray = new Image();
imgbackgray.src = "images/grayarrow.gif";
var imgfolder = new Image();
imgfolder.src = "images/folder.gif";
var imggrayfolder = new Image();
imggrayfolder.src = "images/grayfolder.gif";
//历史记录数组栈
var arrhistory=new Array();
var hisi=0;
//用来确定要返回文件名
function check()
{
if (document.all.filename.value=="")
{
alert("请先选择文件");
return false;
}
else
{
window.returnValue =document.f1.folder.value+document.all.filename.value;
window.close();
}
}
//取得XML文件的内容
function getuserlist(url)
{ var oXMLDoc = new ActiveXObject('MSXML');
oXMLDoc.url = url;
var ooRoot=oXMLDoc.root;
return ooRoot;
}
//当选中一个文件时,把这个值返回给文本框
function addfile(txt)
{
document.all.filename.value=txt;
}
var first=1;//定义一个全局变量
function userlist(folders,ti)//列出所选框
{document.f1.folder.value=folders;
filebox.document.body.innerHTML="正在加载文件,请稍侯...";
var strshow="";
var timeoutid=null;
var newfolder="";
var arrfolder=new Array();
var arrff=new Array();
var blankstr="";
var oItem;
//确定历史状态
hisi+=ti;
arrhistory[hisi]=folders;
if (hisi==0)
{
arrow.innerHTML="<img src=\"images/grayarrow.gif\">";
}
else
{
arrow.innerHTML="<img src=\"images/arrow.gif\" border=0 style=\"cursor:hand\" onclick=\"userlist('"+arrhistory[hisi-1]+"',-1)\" onmouseover=\"this.src='images/arrow_over.gif'\" onmouseout=\"this.src='images/arrow.gif'\">";
}
//确定当前的文件夹
if (document.f1.folder.value=="")
{
folderid.innerHTML="<img src=\"images/grayfolder.gif\">"
}
else
{newsfolder=checkfolder(document.f1.folder.value)
folderid.innerHTML="<img src=\"images/folder.gif\" border=0 style=\"cursor:hand\" onclick=\"userlist('"+newsfolder+"',1)\" onmouseover=\"this.src='images/folder_over.gif'\" onmouseout=\"this.src='images/folder.gif'\">"
}
//给下拉框赋值
document.all.select.options.length=0;
newfolder=folders;
folderstr=""
var _obj=document.all.select;
var _o=document.createElement("Option");
_o.text="选择文件夹";
_o.value="";
_obj.add(_o);
if (newfolder!="")
{arrfolder=newfolder.split("/")
for(var i=0;i<arrfolder.length-1;i++)
{blankstr+=" ";
folderstr+=arrfolder[i]+"/";
_o=document.createElement("Option");
_o.text=blankstr+arrfolder[i];
_o.value=folderstr;
_obj.add(_o);
}
}
document.all.select.options[document.all.select.options.length-1].selected=true;
url="getfolder.asp.gl?folder="+folders;
oRoot=getuserlist(url)
strshow="<table class=file cellspacing=0 cellpadding=0>";
len=oRoot.children.length;
if (len==1)
{oItem = oRoot.children.item(0);
if(oItem.children.item(0).text=="empty")
strshow="没有文件和文件夹了";
else
{
if(oItem.children.item(0).text=="folder")
{
strshow+="<tr><td><A href=\"javascript:parent.userlist('"+folders+oItem.children.item(1).text+"/"+"',1)\"><img src=\"images/mediafolder.gif\" border=0 >"+oItem.children.item(1).text+"</A></td></tr>";
}
else
{
strshow+="<tr><td><a href=\"javascript:parent.addfile('"+oItem.children.item(1).text+"')\" ><img src=\"images/mediafile.gif\" border=0>"+oItem.children.item(1).text+"</A></td></tr>";
}
}
strshow+="</table>"
}
else{
//数据入栈
for(i=0;i<len;i++)
{ oItem = oRoot.children.item(i);
if(oItem.children.item(0).text=="folder")
{
arrff[i]="<A href=\"javascript:parent.userlist('"+folders+oItem.children.item(1).text+"/"+"',1)\"><img src=\"images/mediafolder.gif\" border=0>"+oItem.children.item(1).text+"</A>";
}
else
{
arrff[i]="<A href=\"javascript:parent.addfile('"+oItem.children.item(1).text+"')\"><img src=\"images/mediafile.gif\" border=0 height=12>"+oItem.children.item(1).text+"</A>";
}
}
//取得要输出的列数
if (len<=6)
{x=1;
y=6;}
else
{x=len/6;
y=6;}
for(var i=0;i<y;i++)
{strshow+="<tr>"
for(var j=0;j<x;j++)
{ponits=j*y+i;
if (ponits>=len)
{
strshow+="<td> </td>";
}
else
{
strshow+="<td>"+arrff[ponits]+"</td>";
}
}
strshow+="</tr>"
}
strshow+="</table>"
}
filebox.document.body.innerHTML=strshow;
}
//-->
</SCRIPT>
<script LANGUAGE="vbscript">
function checkfolder(folderstr)
if (folderstr="" or instr(folderstr,"/")=instrrev(folderstr,"/")) then
checkfolder=""
else
nfolder=left(folderstr,len(folderstr)-1)
checkfolder=left(nfolder,instrrev(nfolder,"/"))
end if
end function
</script>
</HEAD>
<BODY style="margin:0" bgColor=menu onload="javascript:userlist('',0)">
<table width="443" border="0" cellspacing="0">
<tr>
<td height="36"><table width="409" border="0">
<tr>
<td width="73" align="right">查找范围(<u>I</u>):</td>
<td width="214"><select name="select" id="select" size="1" onchange="javascript:userlist(this.value,1);">
</select></td>
<td width="22" valign="baseline" id="arrow" align=right></td>
<td width="20" valign="middle" id="folderid"></td>
<td width="20" align="left"><img src="images/md.gif" width="16" height="15"></td>
<td width="28" align="left"><img src="images/viewtype.gif" width="23" height="14"></td>
</tr>
</table></td>
</tr>
<tr>
<td height="120"><table width="100%" height="100%" border="0">
<tr>
<td width="9"> </td>
<td >
<iframe src="blank.htm" width=415 height=120 id="filebox"></iframe></td>
<td width="13"> </td>
</tr>
</table></td>
</tr>
<tr>
<td height="60"><table width="100%" border="0">
<FORM METHOD=POST ACTION="" name="f1">
<input type="hidden" name="folder" value="">
<tr>
<td width="85" align="right">文件名(<u>N</u>): </td>
<td width="254"><input type="text" id="filename" size="34"></td>
<td><button onclick="javascript:return check()"> 打开(<u>O</U>)</button></td>
</tr>
</FORM>
<tr>
<td align="right">文件类型(<u>T</u>):</td>
<td><select name="select2" class=s2>
<option>流媒体文件(*.asf,*.wmv,*.wma)</option>
</select></td>
<td><input type="button" name="Submit" value=" 取消 " onclick="window.close();"></td>
</tr>
</table></td>
</tr>
</table>
</BODY>
</HTML>
里面还有一个小文件blank.htm用来定义文件和文件夹显示的样式
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<style>
td{font-size:9pt}
body{font-size:9pt}
.file A{COLOR: #000000; TEXT-DECORATION: none;font-size:9pt}
.file A:visited{COLOR: #000000; TEXT-DECORATION: none;font-size:9pt}
.file A:hover {COLOR: #000000; TEXT-DECORATION: none;font-size:9pt}
</style>
</HEAD>
<BODY style="margin: 0pt">
</BODY>
</HTML>
调用的时候用以下函数,就可以实现以假乱真的服务器端选择文件的效果
function selectfile()
{
var arr = showModalDialog("selectfile.asp?temp="+Math.random(), "", "dialogWidth:453px; dialogHeight:252px; status:0;help:1");
if (arr != null)
{
return arr
}
}
<%
'written by Linzhang Chen ,2003-4-20
' 转载请注明出处和保留此版权信息
response.write "<?xml version=""1.0"" encoding=""GB2312""?>"&chr(13)
response.write "<mediafile>"&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 "<file>"&chr(13)
response.write "<ftype>folder</ftype>"&chr(13)
response.write "<fname>"&fd.name&"</fname>"&chr(13)
response.write "</file>"&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 "<file>"&chr(13)
response.write "<ftype>file</ftype>"&chr(13)
response.write "<fname>"&fname&"</fname>"&chr(13)
response.write "</file>"&chr(13)
count=count+1
end if
next
'如果该目录下没有文件,就发一个空元素
if count=0 then
response.write "<file>"&chr(13)
response.write "<ftype>empty</ftype>"&chr(13)
response.write "<fname>0</fname>"&chr(13)
response.write "</file>"&chr(13)
end if
response.write "</mediafile>"
set ff=nothing
set f=nothing
set fso=nothing
%>
下面就是客户端的JS的功夫了(selectfile.asp)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> 选择视频文件 </TITLE>
<style>
td{font-size:9pt}
select{width:210}
.s2{width:250}
</style>
<SCRIPT LANGUAGE="javascript">
<!--
/*written by Linzhang Chen ,2003-4-20
转载请注明出处和保留此版权信息 */
//预装载图片
var imgback = new Image();
imgback.src = "images/arrow.gif";
var imgbackgray = new Image();
imgbackgray.src = "images/grayarrow.gif";
var imgfolder = new Image();
imgfolder.src = "images/folder.gif";
var imggrayfolder = new Image();
imggrayfolder.src = "images/grayfolder.gif";
//历史记录数组栈
var arrhistory=new Array();
var hisi=0;
//用来确定要返回文件名
function check()
{
if (document.all.filename.value=="")
{
alert("请先选择文件");
return false;
}
else
{
window.returnValue =document.f1.folder.value+document.all.filename.value;
window.close();
}
}
//取得XML文件的内容
function getuserlist(url)
{ var oXMLDoc = new ActiveXObject('MSXML');
oXMLDoc.url = url;
var ooRoot=oXMLDoc.root;
return ooRoot;
}
//当选中一个文件时,把这个值返回给文本框
function addfile(txt)
{
document.all.filename.value=txt;
}
var first=1;//定义一个全局变量
function userlist(folders,ti)//列出所选框
{document.f1.folder.value=folders;
filebox.document.body.innerHTML="正在加载文件,请稍侯...";
var strshow="";
var timeoutid=null;
var newfolder="";
var arrfolder=new Array();
var arrff=new Array();
var blankstr="";
var oItem;
//确定历史状态
hisi+=ti;
arrhistory[hisi]=folders;
if (hisi==0)
{
arrow.innerHTML="<img src=\"images/grayarrow.gif\">";
}
else
{
arrow.innerHTML="<img src=\"images/arrow.gif\" border=0 style=\"cursor:hand\" onclick=\"userlist('"+arrhistory[hisi-1]+"',-1)\" onmouseover=\"this.src='images/arrow_over.gif'\" onmouseout=\"this.src='images/arrow.gif'\">";
}
//确定当前的文件夹
if (document.f1.folder.value=="")
{
folderid.innerHTML="<img src=\"images/grayfolder.gif\">"
}
else
{newsfolder=checkfolder(document.f1.folder.value)
folderid.innerHTML="<img src=\"images/folder.gif\" border=0 style=\"cursor:hand\" onclick=\"userlist('"+newsfolder+"',1)\" onmouseover=\"this.src='images/folder_over.gif'\" onmouseout=\"this.src='images/folder.gif'\">"
}
//给下拉框赋值
document.all.select.options.length=0;
newfolder=folders;
folderstr=""
var _obj=document.all.select;
var _o=document.createElement("Option");
_o.text="选择文件夹";
_o.value="";
_obj.add(_o);
if (newfolder!="")
{arrfolder=newfolder.split("/")
for(var i=0;i<arrfolder.length-1;i++)
{blankstr+=" ";
folderstr+=arrfolder[i]+"/";
_o=document.createElement("Option");
_o.text=blankstr+arrfolder[i];
_o.value=folderstr;
_obj.add(_o);
}
}
document.all.select.options[document.all.select.options.length-1].selected=true;
url="getfolder.asp.gl?folder="+folders;
oRoot=getuserlist(url)
strshow="<table class=file cellspacing=0 cellpadding=0>";
len=oRoot.children.length;
if (len==1)
{oItem = oRoot.children.item(0);
if(oItem.children.item(0).text=="empty")
strshow="没有文件和文件夹了";
else
{
if(oItem.children.item(0).text=="folder")
{
strshow+="<tr><td><A href=\"javascript:parent.userlist('"+folders+oItem.children.item(1).text+"/"+"',1)\"><img src=\"images/mediafolder.gif\" border=0 >"+oItem.children.item(1).text+"</A></td></tr>";
}
else
{
strshow+="<tr><td><a href=\"javascript:parent.addfile('"+oItem.children.item(1).text+"')\" ><img src=\"images/mediafile.gif\" border=0>"+oItem.children.item(1).text+"</A></td></tr>";
}
}
strshow+="</table>"
}
else{
//数据入栈
for(i=0;i<len;i++)
{ oItem = oRoot.children.item(i);
if(oItem.children.item(0).text=="folder")
{
arrff[i]="<A href=\"javascript:parent.userlist('"+folders+oItem.children.item(1).text+"/"+"',1)\"><img src=\"images/mediafolder.gif\" border=0>"+oItem.children.item(1).text+"</A>";
}
else
{
arrff[i]="<A href=\"javascript:parent.addfile('"+oItem.children.item(1).text+"')\"><img src=\"images/mediafile.gif\" border=0 height=12>"+oItem.children.item(1).text+"</A>";
}
}
//取得要输出的列数
if (len<=6)
{x=1;
y=6;}
else
{x=len/6;
y=6;}
for(var i=0;i<y;i++)
{strshow+="<tr>"
for(var j=0;j<x;j++)
{ponits=j*y+i;
if (ponits>=len)
{
strshow+="<td> </td>";
}
else
{
strshow+="<td>"+arrff[ponits]+"</td>";
}
}
strshow+="</tr>"
}
strshow+="</table>"
}
filebox.document.body.innerHTML=strshow;
}
//-->
</SCRIPT>
<script LANGUAGE="vbscript">
function checkfolder(folderstr)
if (folderstr="" or instr(folderstr,"/")=instrrev(folderstr,"/")) then
checkfolder=""
else
nfolder=left(folderstr,len(folderstr)-1)
checkfolder=left(nfolder,instrrev(nfolder,"/"))
end if
end function
</script>
</HEAD>
<BODY style="margin:0" bgColor=menu onload="javascript:userlist('',0)">
<table width="443" border="0" cellspacing="0">
<tr>
<td height="36"><table width="409" border="0">
<tr>
<td width="73" align="right">查找范围(<u>I</u>):</td>
<td width="214"><select name="select" id="select" size="1" onchange="javascript:userlist(this.value,1);">
</select></td>
<td width="22" valign="baseline" id="arrow" align=right></td>
<td width="20" valign="middle" id="folderid"></td>
<td width="20" align="left"><img src="images/md.gif" width="16" height="15"></td>
<td width="28" align="left"><img src="images/viewtype.gif" width="23" height="14"></td>
</tr>
</table></td>
</tr>
<tr>
<td height="120"><table width="100%" height="100%" border="0">
<tr>
<td width="9"> </td>
<td >
<iframe src="blank.htm" width=415 height=120 id="filebox"></iframe></td>
<td width="13"> </td>
</tr>
</table></td>
</tr>
<tr>
<td height="60"><table width="100%" border="0">
<FORM METHOD=POST ACTION="" name="f1">
<input type="hidden" name="folder" value="">
<tr>
<td width="85" align="right">文件名(<u>N</u>): </td>
<td width="254"><input type="text" id="filename" size="34"></td>
<td><button onclick="javascript:return check()"> 打开(<u>O</U>)</button></td>
</tr>
</FORM>
<tr>
<td align="right">文件类型(<u>T</u>):</td>
<td><select name="select2" class=s2>
<option>流媒体文件(*.asf,*.wmv,*.wma)</option>
</select></td>
<td><input type="button" name="Submit" value=" 取消 " onclick="window.close();"></td>
</tr>
</table></td>
</tr>
</table>
</BODY>
</HTML>
里面还有一个小文件blank.htm用来定义文件和文件夹显示的样式
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<style>
td{font-size:9pt}
body{font-size:9pt}
.file A{COLOR: #000000; TEXT-DECORATION: none;font-size:9pt}
.file A:visited{COLOR: #000000; TEXT-DECORATION: none;font-size:9pt}
.file A:hover {COLOR: #000000; TEXT-DECORATION: none;font-size:9pt}
</style>
</HEAD>
<BODY style="margin: 0pt">
</BODY>
</HTML>
调用的时候用以下函数,就可以实现以假乱真的服务器端选择文件的效果
function selectfile()
{
var arr = showModalDialog("selectfile.asp?temp="+Math.random(), "", "dialogWidth:453px; dialogHeight:252px; status:0;help:1");
if (arr != null)
{
return arr
}
}
无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com
暂无评论...
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。
更新日志
2024年11月16日
2024年11月16日
- 魔兽世界wlk恶魔术士一键输出宏是什么 wlk恶魔术士一键输出宏介绍
- 医学爱好者狂喜:UP主把医学史做成了格斗游戏!
- PS5 Pro评分解禁!准备升级入手吗?
- 我们盘点了近期火热的国产单机游戏!《琉隐神渡》等 你期待哪款?
- 2019年第12届广州影音展双碟纪念版ADMS2CD[MP3/WAV]
- 黄安《救姻缘》台首版[WAV+CUE]
- 模拟之声慢刻CD《柏林之声4》[正版CD低速原抓WAV+CUE]
- 李宗盛 《李宗盛经典金曲》[WAV+CUE][1G]
- 周华健《粤语精选》[WAV+CUE][1G]
- 蔡婧2024《天空》HQCDII头版限量编号[WAV+CUE][1G]
- 陈奂仁.2011-谁是陈奂仁【BBS】【FLAC分轨】
- 群星.2024-幻乐森林影视原声带【韶愔音乐】【FLAC分轨】
- 黎明.1999-向往金色的黎明新歌+精选2CD【环球】【WAV+CUE】
- 发烧女声Méav《美芙的祈祷》发烧女声 [WAV+CUE][820M]
- 雷婷 《我的爱回不来》紫银合金AQCD [WAV+CUE][1G]