ASP

本类阅读TOP10

·asp常用数据库连接方法和技巧
·无组件生成BMP验证码
·一些常用的辅助代码 (网络收藏)
·JavaScript实现的数据表格:冻结列、调整列宽和客户端排序
·VisualStudio.NET_2003及其 MSDN 下载地址
·ASP模拟MVC模式编程
·图片以二进制流输出到网页
·MD5加密算法 ASP版
·ASP.NET编程中的十大技巧
·改进 ASP 的字符串处理性能

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
在服务器端选择文件

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

  一个在服务器端选择文件的小程序,在要插入服务器端的文件,例如服务器端已经上传的图片,或者是菜单管理中选择要执行的文件,都是有用的,当然,还可以改作它用,就看你的需要了。

  限于时间,没能打它做成像windows的打开文件窗口一样的效果,哪位网友做了,告诉一声啊,迟些我自己抽得出时间也会做的,希望能与大家一起进步。

<%@ Language=VBScript codePage="936"%>
<% option explicit %>

<%
 function getFileName(strPath)
  dim filename
  filename = mid(strPath,instrrev(strPath,"\")+1)
  getFileName = filename
 end function
%>

<HTML>
<HEAD>
<title>Noteless Valley(lijun.org)程序示例</title>
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" Content="Microsoft Visual Studio.NET 7.0">
<style type=text/css>
BODY
{
 font-size: 16px;
 border-top-style: none;
 font-family: Verdana, 宋体;
 border-right-style: none;
 border-left-style: none;
 background-color: white;
 border-bottom-style: none;
}
A
{
 text-decoration: none;
}
A:hover
{
 text-decoration: underline;
}
</style>

<script language=javascript>
 function selFile(filename) {
  lblMsg.innerText = filename;
 }
</script>
</HEAD>
<body>
<%
 dim strSvrPath, strCurrentDirectory
 strSvrPath = request.QueryString("path")
 if strSvrPath = "" then 
  strSvrPath = request.ServerVariables("SCRIPT_NAME")
  strSvrPath = mid(strSvrPath,1,instrrev(strSvrPath,"/"))   '在这里设定初始目录,此处我设为根目录
 end if
 strCurrentDirectory = server.MapPath(strSvrPath)
 response.Write "当前目录:" & strSvrPath & "<br>"
 
 dim fso, folder, subfolder, files, item
 set fso = server.CreateObject("scripting.filesystemobject")
 set folder = fso.GetFolder(strCurrentDirectory)
 set subfolder = folder.SubFolders
 
 if strSvrPath <> "/" then
  response.Write "<a href=?path=" & mid(strSvrPath,1,instrrev(mid(strSvrPath,1,len(strSvrPath)-1),"/")) & ">[To Parent Directory]</a>" & "<br>"
 end if
 for each item in subfolder
  response.Write "<a href=?path=" & strSvrPath & getFileName(item) & "/><font face=wingdings>0</font>" & _
          getFileName(item) & "</a><br>"
 next
 
 set files = folder.Files
 for each item in files
 '取绝对路径
 ' response.Write "<a href=javascript:selFile('" & strSvrPath & getFileName(item) & _
 '         "');><font face=wingdings>3</font>" & getFileName(item) & "</a><br>"
 '取文件名
 ' response.Write "<a href=javascript:selFile('" & getFileName(item) & "');><font face=wingdings>3</font>" & _
 '         getFileName(item) & "</a><br>"
 '取相对某目录的相对路径,本例为“/myweb/”
  response.Write "<a href=javascript:selFile('" & replace(strSvrPath,"/myweb/","") & getFileName(item) & "');><font face=wingdings>3</font>" & _
          getFileName(item) & "</a><br>"
 next
 set fso = nothing
%>
<p id=lblMsg></p>
</body>
</HTML>




相关文章

相关软件