An URL to a Windows shared folder

217,642

Solution 1

I think there are two issues:

  1. You need to escape the slashes.
  2. Browser security.

Explanation:

  1. 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:)

  2. Firefox will try to prevent cross site scripting. My solution was to modify prefs.js in 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");
    

Solution 2

File protocol URIs are like this

file://[HOST]/[PATH]

that's why you often see file URLs like this (3 slashes)

file:///c:\path\...

So if the host is server01, you want

file://server01/folder/path....

This is according to the wikipedia page on file URI scheme and checks out with .NET's Uri.IsWellFormedUriString method.

Solution 3

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.

If this solution is appropriate. these are the steps:

  1. download apache hhtp server from one of the mirrors http://httpd.apache.org/download.cgi

  2. unzip/install (if msi) it to the directory e.g C:\opt\Apache (the instruction is for windows)

  3. map the network forlder as a local drive on windows (\server\folder to let's say drive H:)

  4. open conf/httpd.conf file

  5. make sure the next line is present and not commented

    LoadModule autoindex_module modules/mod_autoindex.so

  6. Add directory configuration

<Directory "H:/path">

Options +Indexes

AllowOverride None

Order allow,deny

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

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. 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.
Share:
217,642
alex
Author by

alex

Updated on July 09, 2022

Comments

  • alex
    alex almost 2 years

    Is there a way to incorporate a working link to a Windows shared folder into an HTML page? E.g. a link to \\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.)

    I've tried a few tricks with file:// scheme, but none of them seemed to work.

  • alex
    alex about 13 years
    Yes, browser security is the issue. But I don't know if target browser is Firefox. Any other ideas?
  • alex
    alex about 13 years
    I think this won't work unless the HTML itself is loaded with file:// URI scheme. At least it doesn't work with the WebKit-based Chrome.
  • Bill
    Bill about 13 years
    Take a look at the answer to a similar question, where IE should work, Firefox can be adjusted, but other major browsers block this. stackoverflow.com/questions/855614
  • StanLe3
    StanLe3 about 6 years
    Do I need to configure browser's settings first? Cheers!