简体   繁体   English

Windows注册表或IE中的受信任脚本设置

[英]Trusted Scripts Setting in Windows Registry or IE

I am creating a directory of files for an internal website. 我正在为内部网站创建文件目录。 The user will access the page and insert the location and filename and submit the information to a database. 用户将访问该页面并插入位置和文件名,并将信息提交到数据库。 I tried using file upload to open Windows Explorer so the user can locate the file and path. 我尝试使用文件上载打开Windows资源管理器,以便用户可以找到文件和路径。 However, asp file upload will not allow me to capture the path on the client side. 但是,asp文件上传不会允许我在客户端捕获路径。 Since this is an internal website, does Internet Explorer or Windows Registry have a permissions setting for trusted scripts similar to trusted sites? 由于这是一个内部网站,Internet Explorer或Windows Registry是否具有类似于受信任站点的受信任脚本的权限设置?

I created a JQuery Script to copy the the path to a textbox but I get a error message saying "C:\\fakepath\\test.pdf". 我创建了一个JQuery脚本,将路径复制到文本框,但是收到一条错误消息,内容为“ C:\\ fakepath \\ test.pdf”。 test.pdf is the filename but c:\\fakepath is not the path. test.pdf是文件名,但c:\\ fakepath不是路径。 I have tried multiple server variables but those just tell the paths on the server end. 我尝试了多个服务器变量,但这些变量只告诉服务器端的路径。

    <script>
        $(document).ready(function(){
        $("#button").click(function(){
         $("#text1").val($("#text").val());
         });
         });
 </script>
 <input type="file" id="text" />
 <input type="text" id="text1" />
 <input type="button" value="Click Me!" id="button" />

To access the local path you need to use ActiveX object in your web page. 要访问本地路径,您需要在网页中使用ActiveX对象。 It can help you to get the path in IE. 它可以帮助您获取IE中的路径。

For working with Files and directory you should make a server object as Scripting.FileSystemObject then with GetDirectory() method can get a directory object. 为了使用文件和目录,应将服务器对象作为Scripting.FileSystemObject,然后使用GetDirectory()方法可以获取目录对象。

Sample code: 样例代码:

 var Fo =new ActiveXObject("Scripting.FileSystemObject"); var StrOut = new String(); var FileName = new String(); var Extention = new String(); function FindFile(FOo) { var FSo = new Enumerator(FOo.Files); for(i=0;!FSo.atEnd();FSo.moveNext()) { if(FileName == "*" || FSo.item().name.slice(0,FSo.item().name.lastIndexOf(".")).toLowerCase().indexOf(FileName)>-1) if(Extention == "*" || FSo.item().name.slice(FSo.item().name.lastIndexOf(".")+1).toLowerCase().indexOf(Extention)>-1){ StrOut += "<tr "+ ((i%2)? "":"bgcolor=#DDAA55") +"><td width=50%><font class=find>" + FSo.item().path + "</font></td><td width=25%><font class=find>" + FSo.item().type + "</font></td><td width=50%><font class=find>"+ String(FSo.item().size/(1024*1024)).slice(0,3) +" MB</font></td></tr>"; i++ } } } function Scan() { FileName = (search.value.lastIndexOf(".")>-1)? search.value.slice(0,search.value.lastIndexOf(".")):(search.value.length>0)? search.value.toLowerCase():"*"; //Get Searched File Name Extention = (search.value.lastIndexOf(".")>-1)? search.value.slice(search.value.lastIndexOf(".")+1).toLowerCase():"*"; // Get Searched File Extention Name if(path.value.length>0 && Fo.FolderExists(path.value)){ StrOut = "<table border=0 width=100% cellspacing=0>" FindFile(Fo.GetFolder(path.value)); outPut.innerHTML = StrOut+"</table>"; } else alert("Insert Correct Path Address"); } 

For detailed information and example code, You can refer link below and download the sample file. 有关详细信息和示例代码,您可以参考下面的链接并下载示例文件。

Find files with JavaScript 使用JavaScript查找文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM