Html Windows 共享文件夹的 URL
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5796215/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
An URL to a Windows shared folder
提问by alex
Is there a way to incorporate a workinglink to a Windows shared folder into an HTML page? E.g. a link to \\server\folder\path
?
有没有办法将Windows 共享文件夹的工作链接合并到 HTML 页面中?例如链接到\\server\folder\path
?
For simplicity, let's say the page will be opened on a Windows machine (and on the same intranet where the server
is located, of course.)
为简单起见,假设该页面将在 Windows 机器上打开(当然,在 其所在的同一 Intranet 上server
。)
I've tried a few tricks with file://
scheme, but none of them seemed to work.
我已经尝试了一些使用file://
计划的技巧,但它们似乎都不起作用。
采纳答案by Bill
I think there are two issues:
我认为有两个问题:
- You need to escape the slashes.
- Browser security.
- 你需要逃避斜线。
- 浏览器安全。
Explanation:
解释:
I checked one of mine, I have the pattern:
<a href="file://///server01\fshare\dir1\dir2\dir3">useful link </a>
Please note that we ended up with 5 slashes after the protocol (
file:
)Firefox will try to prevent cross site scripting. My solution was to modify prefs.jsin the profile directory. You will add two lines:
user_pref("capability.policy.localfilelinks.checkloaduri.enabled", "allAccess"); user_pref("capability.policy.localfilelinks.sites", "http://mysite.company.org");
我检查了我的一个,我有这样的模式:
<a href="file://///server01\fshare\dir1\dir2\dir3">useful link </a>
请注意,我们在协议 (
file:
)后以 5 个斜杠结束Firefox 将尝试阻止跨站点脚本。我的解决方案是修改配置文件目录中的prefs.js。您将添加两行:
user_pref("capability.policy.localfilelinks.checkloaduri.enabled", "allAccess"); user_pref("capability.policy.localfilelinks.sites", "http://mysite.company.org");
回答by Jim W says reinstate Monica
File protocol URIs are like this
文件协议URIs是这样的
file://[HOST]/[PATH]
文件://[主机]/[路径]
that's why you often see file URLs like this (3 slashes) file:///c:\path...
这就是为什么您经常看到这样的文件 URL(3 个斜杠)file:///c:\path...
So if the host is server01, you want
所以如果主机是server01,你想要
file://server01/folder/path....
文件://server01/文件夹/路径....
This is according to the wikipedia page on file:// protocols and checks out with .NET's Uri.IsWellFormedUriString method.
这是根据 file:// 协议上的维基百科页面,并使用 .NET 的 Uri.IsWellFormedUriString 方法进行检查。
回答by Pavlonator
If you are allowed to go further then javascript/html facilities - I would use the apache web server to represent your directory listing via http.
如果允许您更进一步,则使用 javascript/html 工具 - 我将使用 apache 网络服务器通过 http 表示您的目录列表。
If this solution is appropriate. these are the steps:
如果这个解决方案合适。这些是步骤:
download apache hhtp server from one of the mirrors http://httpd.apache.org/download.cgi
unzip/install (if msi) it to the directory e.g C:\opt\Apache (the instruction is for windows)
map the network forlder as a local drive on windows (\server\folder to let's say drive H:)
open conf/httpd.conf file
make sure the next line is present and not commented
LoadModule autoindex_module modules/mod_autoindex.so
Add directory configuration
从镜像之一下载 apache hhtp 服务器http://httpd.apache.org/download.cgi
将其解压缩/安装(如果是 msi)到目录,例如 C:\opt\Apache(该指令适用于 Windows)
将网络文件夹映射为 Windows 上的本地驱动器(\server\folder 比方说驱动器 H:)
打开 conf/httpd.conf 文件
确保下一行存在并且没有注释
LoadModule autoindex_module modules/mod_autoindex.so
添加目录配置
<Directory "H:/path">
<Directory "H:/path">
Options +Indexes
Options +Indexes
AllowOverride None
AllowOverride None
Order allow,deny
Order allow,deny
Allow from all
Allow from all
</Directory>
7. Start the web server and make sure the directory listingof the remote folder is available by http. hit localhost/path
8. use a frame inside your web page to access the listing
</Directory>
7. 启动Web 服务器并确保远程文件夹的目录列表可通过http 访问。点击 localhost/path 8. 使用网页内的框架访问列表
What is missed:1. you mignt need more fancy configuration for the host name, refer to Apache Web Server docs. Register the host name in DNS server
遗漏了什么:1. 您可能不需要更多花哨的主机名配置,请参阅 Apache Web Server 文档。在 DNS 服务器中注册主机名
- the mapping to the network drive might not work, i did not check. As a posible resolution - host your web server on the same machine as smb server.
- 到网络驱动器的映射可能不起作用,我没有检查。作为一个可行的解决方案 - 将您的 Web 服务器与 smb 服务器托管在同一台机器上。
回答by Pavlonator
This depend on how you want to incorporate it. The scenario 1. click on a link 2. explorer window popped up
这取决于您希望如何合并它。场景 1. 点击链接 2. 弹出资源管理器窗口
<a href="\server\folder\path" target="_blank">click</a>
If there is a need in a fancy UI - then it will barely serve as a solution.
如果需要花哨的 UI - 那么它几乎不能作为解决方案。