How do I enter file paths into a link? (Both local and UNC Names)
The "correct" link format is
file:///
followed by the path to the file, using forward slashes throughout:
[[file:///home/user/somefile]]
[[file:///C:/somefile.txt]]
Windows shares can be referenced in a link, with some restrictions / considerations:
- Write the link using
file:///
(3 forward slashes), followed by the UNC name \\server\path\filename
- Technically the forward slash should be used throughout the link, but the backslash works on windows platforms
- Some browsers appear to auto-convert a single slash
file:/some/file
to the required 3-slashes file:///some/file
. It's probably safer to use the 3 slash format.
[[file://///myserver/path/somefile.doc]]
- Under some conditions, embedded spaces must be encoded as %20
- Simple square bracket links without link text must have embedded spaces encoded
-
[[file:///\\path\file with spaces][link text]]
does not need to be encoded because it has the explicit link text.
-
[[file:///\\path\file%20with%20spaces]]
must be encoded as shown here.
- Explicit HTML tags must have embedded spaces encoded.
-
<a href="file:///\\server\My%20Documents\SomeFile>Link to file</a>
- WysiwygPlugin Version 1.13 properly preserves the %20 encoded spaces and will also encode spaces when saving the topic. Earlier versions of WysiwygPlugin might cause issues.
- It's the client that reads the file, not the server. so the client must be part of the Windows domain and have access to the file.
- Local Links are a significant security exposure and are blocked by recent browsers. Enable at your own risk.
- Internet Explorer 8 & 9 (and possibly IE7) will only allow clickable links that are from sites in the Intranet or Trusted zone.
- Firefox blocks these links by default. See this mozillaZine article for details on why they are blocked and how to enable local links.
- The NoScript Firefox add-on can permit local links on trusted sites.
- Chrome and Firefox also have a "LocalLinks" plugin that can enable linking to local files.