如何让html链接打开文件夹

时间:2022-02-11 00:30:01

I need to let users of an application open a folder by clicking a link inside a web page. The path of the folder is on the network and can be accessed from everywhere. I'm probably sure there is no easy way to do this, but maybe I'm mistaken?

我需要让应用程序的用户通过点击网页中的链接打开一个文件夹。文件夹的路径在网络上,可以从任何地方访问。我肯定没有简单的方法可以做到这一点,但也许我错了?

6 个解决方案

#1


86  

Do you want to open a shared folder in Windows Explorer? You need to use a file: link, but there are caveats:

要在Windows资源管理器中打开共享文件夹吗?您需要使用一个文件:链接,但有一些注意事项:

  • Internet Explorer will work if the link is a converted UNC path (file://server/share/folder/).
  • 如果链接是转换后的UNC路径(文件://server/share/folder/), Internet Explorer将工作。
  • Firefox will work if the link is in its own mangled form using five slashes (file://///server/share/folder) and the user has disabled the security restriction on file: links in a page served over HTTP. Thankfully IE also accepts the mangled link form.
  • 如果链接使用5个斜杠(文件:////服务器/共享/文件夹),并且用户已经禁用了文件:HTTP上的页面链接的安全限制,那么Firefox将会工作。谢天谢地IE也接受了损坏的链接形式。
  • Opera, Safari and Chrome can not be convinced to open a file: link in a page served over HTTP.
  • Opera、Safari和Chrome不能被说服打开一个文件:通过HTTP服务的页面中的链接。

#2


4  

make sure your folder permissions are set so that a directory listing is allowed then just point your anchor to that folder using chmod 701 (that might be risky though) for example

确保设置了文件夹权限,以便允许目录列表,然后使用chmod 701(这可能有风险)将锚点指向该文件夹

<a href="./downloads/folder_i_want_to_display/" >Go to downloads page</a>

make sure that you have no index.html any index file on that directory

确保没有索引。在该目录上的任何索引文件。

#3


4  

The URL file://[servername]/[sharename] should open an explorer window to the shared folder on the network.

URL文件://[servername]/[sharename]应该为网络上的共享文件夹打开一个资源管理器窗口。

#4


2  

Using file:///// just doesn't work if security settings are set to even a moderate level.

使用file:///// /如果安全设置设置为中等水平,则不会工作。

If you just want users to be able to download/view files* located on a network or share you can set up a Virtual Directory in IIS. On the Properties tab make sure the "A share located on another computer" is selected and the "Connect as..." is an account that can see the network location.

如果您只是希望用户能够下载/查看位于网络上的文件或共享,您可以在IIS中设置一个虚拟目录。在Properties选项卡上,确保选择了“位于另一台计算机上的共享”,而“Connect as…”是一个可以看到网络位置的帐户。

Link to the virtual directory from your webpage (e.g. http://yoursite/yourvirtualdir/) and this will open up a view of the directory in the web browser.

从您的网页(例如http://yoursite/yourvirtualdir/)链接到虚拟目录,这将打开web浏览器中目录的视图。

*You can allow write permissions on the virtual directory to allow users to add files but not tried it and assume network permissions would override this setting.

*您可以允许在虚拟目录上写入权限,允许用户添加文件,但不尝试,并假定网络权限会覆盖此设置。

#5


1  

Does not work in Chrome, but this other answers suggests a solution via a plugin:

Chrome不支持,但其他答案建议通过插件解决:

Can Google Chrome open local links?

谷歌可以打开本地链接吗?

#6


1  

You can also copy the link address and paste it in a new window to get around the security. This works in chrome and firefox but you may have to add slashes in firefox.

您还可以复制链接地址并将其粘贴到一个新的窗口中,以绕过安全性。这适用于chrome和firefox,但你可能需要在firefox中添加斜线。

#1


86  

Do you want to open a shared folder in Windows Explorer? You need to use a file: link, but there are caveats:

要在Windows资源管理器中打开共享文件夹吗?您需要使用一个文件:链接,但有一些注意事项:

  • Internet Explorer will work if the link is a converted UNC path (file://server/share/folder/).
  • 如果链接是转换后的UNC路径(文件://server/share/folder/), Internet Explorer将工作。
  • Firefox will work if the link is in its own mangled form using five slashes (file://///server/share/folder) and the user has disabled the security restriction on file: links in a page served over HTTP. Thankfully IE also accepts the mangled link form.
  • 如果链接使用5个斜杠(文件:////服务器/共享/文件夹),并且用户已经禁用了文件:HTTP上的页面链接的安全限制,那么Firefox将会工作。谢天谢地IE也接受了损坏的链接形式。
  • Opera, Safari and Chrome can not be convinced to open a file: link in a page served over HTTP.
  • Opera、Safari和Chrome不能被说服打开一个文件:通过HTTP服务的页面中的链接。

#2


4  

make sure your folder permissions are set so that a directory listing is allowed then just point your anchor to that folder using chmod 701 (that might be risky though) for example

确保设置了文件夹权限,以便允许目录列表,然后使用chmod 701(这可能有风险)将锚点指向该文件夹

<a href="./downloads/folder_i_want_to_display/" >Go to downloads page</a>

make sure that you have no index.html any index file on that directory

确保没有索引。在该目录上的任何索引文件。

#3


4  

The URL file://[servername]/[sharename] should open an explorer window to the shared folder on the network.

URL文件://[servername]/[sharename]应该为网络上的共享文件夹打开一个资源管理器窗口。

#4


2  

Using file:///// just doesn't work if security settings are set to even a moderate level.

使用file:///// /如果安全设置设置为中等水平,则不会工作。

If you just want users to be able to download/view files* located on a network or share you can set up a Virtual Directory in IIS. On the Properties tab make sure the "A share located on another computer" is selected and the "Connect as..." is an account that can see the network location.

如果您只是希望用户能够下载/查看位于网络上的文件或共享,您可以在IIS中设置一个虚拟目录。在Properties选项卡上,确保选择了“位于另一台计算机上的共享”,而“Connect as…”是一个可以看到网络位置的帐户。

Link to the virtual directory from your webpage (e.g. http://yoursite/yourvirtualdir/) and this will open up a view of the directory in the web browser.

从您的网页(例如http://yoursite/yourvirtualdir/)链接到虚拟目录,这将打开web浏览器中目录的视图。

*You can allow write permissions on the virtual directory to allow users to add files but not tried it and assume network permissions would override this setting.

*您可以允许在虚拟目录上写入权限,允许用户添加文件,但不尝试,并假定网络权限会覆盖此设置。

#5


1  

Does not work in Chrome, but this other answers suggests a solution via a plugin:

Chrome不支持,但其他答案建议通过插件解决:

Can Google Chrome open local links?

谷歌可以打开本地链接吗?

#6


1  

You can also copy the link address and paste it in a new window to get around the security. This works in chrome and firefox but you may have to add slashes in firefox.

您还可以复制链接地址并将其粘贴到一个新的窗口中,以绕过安全性。这适用于chrome和firefox,但你可能需要在firefox中添加斜线。