144

I am linking on an intranet page to a local file on a shared drive:

<a href="file:///s:/test.xls"> Test</a>

This works in IE and Firefox with an addon called local link.

How can I get this to open in Google Chrome?

BSMP
  • 3,862
  • 8
  • 31
  • 41
Andy
  • 1,569
  • 2
  • 13
  • 11

8 Answers8

48

You can't link to file:/// from an HTML document that is not itself a file:/// for security reasons.

Thomas Bonini
  • 40,716
  • 28
  • 117
  • 153
  • 29
    It may be that this is a "Security flaw" but it also provides essential functionality in some instances and Chrome could give us the ability to enable it for certain URL's, with a warning and research to figure out how to do it, rather than just disabling it wholesale – Arcan.NET Dec 11 '15 at 16:54
  • 4
    @Arcan.NET I disagree. This would advocate bad practice and once it's whitespread, it's **yet another social engineering attack vector**. – bytecode77 May 16 '18 at 12:47
  • 5
    @bytecode77 You have a good point. However I would argue that it is bad practice only under certain circumstances. For example, what if this was within a corporate intranet with a restricted set of users? While it can be bad practice, those who chose to misuse the feature must be held accountable for their actions rather than having a useful protocol scheme removed so that none may benefit (who also use it appropriately). – Rook Sep 28 '18 at 20:47
  • 1
    Not even local dir with the index.html is allowed to access! How would that be insecure? With that policy thinking it is safest to not use Chrome at all. –  Aug 12 '19 at 15:25
  • 1
    I can see the security vulnerability that this addresses. But it would be a good feature to have to whitelist some addresses - or even only allow for intranet pages - so that trusted sites could have links to files. For example, we have an SSRS report that has links to files on a share. Alternative is as below from @Guilherme Amorim but that results in users downloading endless copies of files rather than opening them on a share – nonpoliticaltag Jul 01 '20 at 15:57
25

This question is dated, but I had the same problem just now, the solution I found was to map a virtual directory in IIS to the networked drive with the documents, so the url became a friendly "http://" address.

Setting virtual directories:

IIS:

http://www.iis.net/configreference/system.applicationhost/sites/site/application/virtualdirectory

Apache:

http://w3shaman.com/article/creating-virtual-directory-apache

Cheers!

Guilherme Amorim
  • 415
  • 5
  • 14
  • Thanks, this helped me out greatly. Not only does this allow me to open files hosted on a different server, it opens them in the browser directly. – D.Galvez Mar 10 '16 at 22:01
  • @D.Galvez Glad it was of use to someone. – Guilherme Amorim Mar 12 '16 at 00:41
  • This helped me!! Thanks so much – AndeeC Oct 04 '16 at 22:25
  • Chrome is a red herring. The solution is in Apache2, via the "virtual directory, as discussed in this Answer. (I wonder if it will solve Firefox.) – Rick James Sep 17 '17 at 03:49
  • Thanks - works great for me! Users wanted to see files over a network share – Cordell Feb 07 '18 at 19:52
  • That doesn't work so well when you are opening the file for editting e.g. an Excel file on a network sahre. – NetMage Apr 28 '20 at 19:52
  • Mapping to a virtual directory works for me in IE and Firefox (prompts to open the file directly, or save), but Chrome downloads the file automatically. If file type is set to open directly, the copy is opened. Is this expected? – user25976 May 05 '20 at 21:14
14

From what I've seen of this the following is true for Firefox and Chrome;

1) If you have a HTML page open from a remote host then file:// links will not work i.e. Your address bar reads http://someserver.domain and the page contains a link such as <a href="file:///S:/sharedfile.txt">

2) If you have a HTML page open from your local host then file:// links will work i.e. your address bar reads file:///C:/mydir/index.html and the page contains a link such as <a href="file:///S:/sharedfile.txt">

For Internet Explorer point 1) does not hold true. A file on your local host can be accessed using the file:// link syntax from a webpage on a remote host. This is considered a security flaw in IE(By who? References?) (and it's there in IE8 too) because a remote host can access files on your local computer without your knowledge .... admittedly they have to get lucky with the filename but there are plenty of commonly named files there with the potential to contain personal/private information.

Dakkaron
  • 4,941
  • 2
  • 32
  • 48
Rory
  • 1
  • 3
  • 12
    "A webpage from a remote host can access files on your local host" What support do you have for this claim? Linking of a file and accessing the file are not the same thing since the remote host cannot read the file and cannot determine if the file exists. Is there a hack I am unaware of? – styfle Apr 30 '14 at 20:43
  • 1
    Doesn't work for me. I'm opening a local file in Chrome with file:///, but it refuses to load other local files. – mcv Dec 23 '16 at 20:37
12

LocalLinks now seems to be obsolete.

LocalExplorer seems to have taken it's place and provides similar functionality:

https://chrome.google.com/webstore/detail/local-explorer-file-manag/eokekhgpaakbkfkmjjcbffibkencdfkl/reviews?hl=en

It's basically a chrome plugin that replaces file:// links with localexplorer:// links, combined with an installable protocol handler that intercepts localexplorer:// links.

Best thing I can find available right now, I have no affiliation with the developer.

  • 1
    Thanks! This extension is really worth it if you want to access a local file from another protocol in Chrome. – Patrick Jan 24 '19 at 11:01
  • A good post that explains how to setup the extension: https://www.alphr.com/browse-and-open-folders-files-chrome/ – AJ AJ Nov 18 '20 at 13:21
6

The LocalLinks extension from the most popular answer didn't work for me (given, I was trying to use file:// to open a directory in windows explorer, not a file), so I looked into another workaround. I found that this "Open in IE" extension is a good workaround: https://chrome.google.com/webstore/detail/open-in-ie/iajffemldkkhodaedkcpnbpfabiglmdi

This isn't an ideal fix, as instead of clicking the link, users will have to right-click and choose Open in IE, but it at least makes the link functional.

One thing to note though, in IE10 (and IE9 after a certain update point) you will have to add the site to your Trusted Sites (Internet Options > Security > Trusted sites). If the site is not in trusted sites, the file:// link does not work in IE either.

BryPie
  • 367
  • 2
  • 6
0

I've just came across the same problem and found the chrome extension Open IE.
That's the only one what works for me (Chrome V46 & V52). The only disadvantefge is, that you need to install an additional program, means you need admin rights.

Stefan
  • 192
  • 12
  • 1
    Open IE opens IE. Why not use IE in the first place. Definitely not a work around. – Mike Jun 23 '17 at 13:10
  • 1
    because IE is outdated, by far not as goog as FF or Chrome but there some internal apps/sites what stil relay on IE – Stefan Jun 26 '17 at 12:52
0

It's not really an anwser but a workaround to open a local link in chrome using python.

Copy the local link you want to run then run the code bellow (using a shortcut), it will open your link.

import win32clipboard
import os

win32clipboard.OpenClipboard()
clipboard_data= win32clipboard.GetClipboardData()
win32clipboard.CloseClipboard()

os.system("start "+clipboard_data)
JinSnow
  • 1,171
  • 4
  • 23
  • 45
-1

Hopefully this helps others in an enterprise setting looking for a solution. My solution after much tinkering was the following:

Follow the steps in the following link to install legacy browser extension and gpo settings: https://support.google.com/chrome/a/answer/3019558?hl=en&ref_topic=3062034

Enabled legacy browser redirect for "file://" through chrome gpo configuration Google Chrome -> Legacy Browser Support -> "Websites to open in alternative browser"

Configure gpo to also install extension: https://chrome.google.com/webstore/detail/enable-local-file-links/nikfmfgobenbhmocjaaboihbeocackld that redirects file:// links to bypass chrome file:// link block.

The extension opens the links which then triggers google chrome to open the link in internet explorer. The result is IE opens a window, then opens the file/folder for the user, then IE closes itself.

diegorodny
  • 114
  • 3