10 | 11 | [](){#top} 12 |
13 | 14 |
15 | 16 |
17 | 18 |
19 | 20 | file URI scheme {#firstHeading .firstHeading lang="en"} 21 | =============== 22 | 23 |
24 | 25 |
26 | 27 | From Wikipedia, the free encyclopedia 28 | 29 |
30 | 31 |
32 | 33 |
34 | 35 |
36 | 37 | Jump to: [navigation](#mw-head), [search](#p-search) 38 | 39 |
40 | 41 |
42 | 43 | +--------------------------------------+--------------------------------------+ 44 | |
| This | 45 | | | article **needs additional citations | 46 | | [![](//upload.wikimedia.org/wikipedi | for | 47 | | a/en/thumb/9/99/Question_book-new.sv | [verification](/wiki/Wikipedia:Verif | 48 | | g/50px-Question_book-new.svg.png){wi | iability "Wikipedia:Verifiability")* | 49 | | dth="50" | *. | 50 | | height="39" | Please | 52 | | edia/en/thumb/9/99/Question_book-new | help [improve this | 53 | | .svg/75px-Question_book-new.svg.png | article](//en.wikipedia.org/w/index. | 54 | | 1.5x, //upload.wikimedia.org/wikiped | php?title=File_URI_scheme&action=edi | 55 | | ia/en/thumb/9/99/Question_book-new.s | t){.external | 56 | | vg/100px-Question_book-new.svg.png 2 | .text} by [adding citations to | 57 | | x"}](/wiki/File:Question_book-new.sv | reliable | 58 | | g){.image} | sources](/wiki/Help:Introduction_to_ | 59 | | | referencing_with_Wiki_Markup/1 "Help | 60 | |
| :Introduction to referencing with Wi | 61 | | | ki Markup/1"). | 62 | | | Unsourced material may be challenged | 63 | | | and removed. *(October 2012)* | 64 | | | *([Learn how and when to remove this | 65 | | | template | 66 | | | message](/wiki/Help:Maintenance_temp | 67 | | | late_removal "Help:Maintenance templ | 68 | | | ate removal"))* | 69 | +--------------------------------------+--------------------------------------+ 70 | 71 | The **file URI scheme** is a [URI 72 | scheme](/wiki/URI_scheme "URI scheme"){.mw-redirect} specified in [RFC 73 | 1630](//tools.ietf.org/html/rfc1630){.external .mw-magiclink-rfc} and 74 | [RFC 1738](//tools.ietf.org/html/rfc1738){.external .mw-magiclink-rfc}, 75 | typically used to retrieve files from within one's own computer. The 76 | [Internet Engineering Task 77 | Force](/wiki/Internet_Engineering_Task_Force "Internet Engineering Task Force") 78 | (IETF) has published a series of [draft 79 | documents](/wiki/Draft_document "Draft document") obsoleting these RFCs. 80 | They say that they are trying to define "a syntax that is compatible 81 | with most extant implementations, while attempting to push towards a 82 | stricter subset of 'ideal' constructs." Doing so involves the 83 | [deprecation](/wiki/Deprecation "Deprecation") of some less common or 84 | outdated constructs, some of which are described below. While they may 85 | work on some current systems, formulations that are not consistent with 86 | the [standardization](/wiki/Standardization "Standardization") process 87 | going forward will not have the useful lifetime that others will. The 88 | drafts are not final, and should be consulted for up to date 89 | information.^[\[1\]](#cite_note-1)^ 90 | 91 |
92 | 93 |
94 | 95 | Contents 96 | -------- 97 | 98 |
99 | 100 | - [1 Format](#Format) 102 | - [2 Meaning of 103 | slash character](#Meaning_of_slash_character) 104 | - [3 Examples](#Examples) 106 | - [3.1 Unix](#Unix) 108 | - [3.2 Windows](#Windows) 110 | - [4 Implementations](#Implementations) 112 | - [4.1 Windows](#Windows_2) 114 | - [4.1.1 Legacy URLs](#Legacy_URLs) 116 | - [4.2 Web 117 | pages](#Web_pages) 118 | - [5 References](#References) 120 | - [6 External 121 | links](#External_links) 122 | 123 |
124 | 125 | Format\[[edit](/w/index.php?title=File_URI_scheme&action=edit§ion=1 "Edit section: Format")\] 126 | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 127 | 128 | A file URI takes the form of 129 | 130 | file://host/path 131 | 132 | where ***host*** is the [fully qualified domain 133 | name](/wiki/Fully_qualified_domain_name "Fully qualified domain name") 134 | of the system on which the *path* is accessible, and ***path*** is a 135 | hierarchical directory path of the form 136 | *directory*/*directory*/.../*name*. If *host* is omitted, it is taken to 137 | be "[localhost](/wiki/Localhost "Localhost")", the machine from which 138 | the URL is being interpreted. Note that when omitting host, the slash is 139 | not omitted (while "file:///foo.txt" is valid, "file://foo.txt" is not, 140 | although some interpreters manage to handle the latter). 141 | 142 | \[[RFC 3986](//tools.ietf.org/html/rfc3986){.external 143 | .mw-magiclink-rfc}\] includes additional information about the treatment 144 | of ".." and "." segments in URIs. 145 | 146 | Meaning of slash character\[[edit](/w/index.php?title=File_URI_scheme&action=edit§ion=2 "Edit section: Meaning of slash character")\] 147 | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 148 | 149 | The **slash character** (/), depending on its position, has different 150 | meanings within a file URL. 151 | 152 | - The // after the *file:* is part of the general syntax of 153 | [URLs](/wiki/Uniform_resource_locator "Uniform resource locator"){.mw-redirect}. 154 | (The double slash // should always appear in a file URL according to 155 | the specification, but in practice many [Web 156 | browsers](/wiki/Web_browser "Web browser") allow it to be omitted). 157 | - The single slash between ***host*** and ***path*** is part of the 158 | syntax of URLs. 159 | - The slashes in ***path*** separate directory names in a hierarchical 160 | system of directories and subdirectories. In this usage, the slash 161 | is a general, system-independent way of separating the parts, and in 162 | a particular host system it might be used as such in any pathname 163 | (as in Unix systems). 164 | 165 | Examples\[[edit](/w/index.php?title=File_URI_scheme&action=edit§ion=3 "Edit section: Examples")\] 166 | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 167 | 168 | ### Unix\[[edit](/w/index.php?title=File_URI_scheme&action=edit§ion=4 "Edit section: Unix")\] 169 | 170 | Here are two [Unix](/wiki/Unix "Unix") examples pointing to the same 171 | /*etc*/*fstab* file: 172 | 173 | file://localhost/etc/fstab 174 | file:///etc/fstab 175 | 176 | ### Windows\[[edit](/w/index.php?title=File_URI_scheme&action=edit§ion=5 "Edit section: Windows")\] 177 | 178 | Here are some examples which may be accepted by some applications on 179 | Windows systems, referring to the same, local file 180 | *c:*\\*WINDOWS*\\*clock.avi* 181 | 182 | file://localhost/c|/WINDOWS/clock.avi 183 | file:///c|/WINDOWS/clock.avi 184 | file://localhost/c:/WINDOWS/clock.avi 185 | 186 | Here is the URI as understood by the Windows Shell 187 | API:^[\[2\]](#cite_note-2)^ 188 | 189 | file:///c:/WINDOWS/clock.avi 190 | 191 | Implementations\[[edit](/w/index.php?title=File_URI_scheme&action=edit§ion=6 "Edit section: Implementations")\] 192 | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 193 | 194 | ### Windows\[[edit](/w/index.php?title=File_URI_scheme&action=edit§ion=7 "Edit section: Windows")\] 195 | 196 | On Microsoft Windows systems, the normal colon (:) after a device letter 197 | has sometimes been replaced by a vertical bar (|) in file URLs. This 198 | reflected the original URL syntax, which made the colon a reserved 199 | character in a path part. 200 | 201 | Since [Internet Explorer 202 | 4](/wiki/Internet_Explorer_4 "Internet Explorer 4"), file URIs have been 203 | standardized on Windows, and should follow the following scheme. This 204 | applies to all applications which use URLMON or SHLWAPI for parsing, 205 | fetching or binding to URIs. To convert a path to a URL, use 206 | `UrlCreateFromPath`, and to convert a URL to a path, use 207 | `PathCreateFromUrl`.^[\[3\]](#cite_note-3)^ 208 | 209 | To access a file "the file.txt", the following might be used. 210 | 211 | For a network location: 212 | 213 | file://hostname/path/to/the%20file.txt 214 | 215 | Or for a local file, the hostname is omitted, but the slash is not (note 216 | the third slash): 217 | 218 | file:///c:/path/to/the%20file.txt 219 | 220 | This is not the same as providing the string "localhost" or the dot "." 221 | in place of the hostname. The string "localhost" will attempt to access 222 | the file as \\\\localhost\\c:\\path\\to\\the file.txt, which will not 223 | work since the colon is not allowed in a share name. The dot "." results 224 | in the string being passed as \\\\.\\c:\\path\\to\\the file.txt, which 225 | will work for local files, but not shares on the local system. For 226 | example file://./sharename/path/to/the%20file.txt will not work, because 227 | it will result in *sharename* being interpreted as part of the 228 | DOSDEVICES namespace, not as a network share. 229 | 230 | The following outline roughly describes the requirements. 231 | 232 | - The colon should be used, and should *not* be replaced with a 233 | vertical bar for Internet Explorer. 234 | - Forward slashes should be used to delimit paths. 235 | - Characters such as the hash (\#) or question mark (?) which are part 236 | of the filename should be 237 | [percent-encoded](/wiki/Percent-encoding "Percent-encoding"). 238 | - Characters which are not allowed in URIs, but which are allowed in 239 | filenames, must also be percent-encoded. For example, any of 240 | "**{}\`\^** " and all control characters. In the example above, the 241 | space in the filename is encoded as %20. 242 | - Characters which are allowed in both URIs and filenames must NOT 243 | be percent-encoded. 244 | - Must not use legacy ACP encodings. (ACP code pages are specified by 245 | DOS CHCP or Windows Control Panel language setting.) 246 | - Unicode characters outside of the [ASCII](/wiki/ASCII "ASCII") range 247 | must be [UTF-8](/wiki/UTF-8 "UTF-8") encoded, and those UTF-8 248 | encodings must be percent-encoded. 249 | 250 | Use the provided functions if possible. If must create a URL 251 | programmatically and cannot access SHLWAPI.dll (for example from script, 252 | or another programming environment where the equivalent functions are 253 | not available) the above outline will help. 254 | 255 | #### Legacy URLs\[[edit](/w/index.php?title=File_URI_scheme&action=edit§ion=8 "Edit section: Legacy URLs")\] 256 | 257 | To aid the installed base of legacy applications on Win32 258 | `PathCreateFromUrl` recognizes certain URLs which do not meet these 259 | criteria, and treats them uniformly. These are called "legacy" file URLs 260 | as opposed to "healthy" file URLs.^[\[4\]](#cite_note-4)^ 261 | 262 | In the past, a variety of other applications have used other systems. 263 | Some added an additional two slashes. For example, 264 | \\\\remotehost\\share\\dir\\file.txt, would become 265 | file:////remotehost/share/dir/file.txt instead of the "healthy" 266 | file://remotehost/share/dir/file.txt. 267 | 268 | ### Web pages\[[edit](/w/index.php?title=File_URI_scheme&action=edit§ion=9 "Edit section: Web pages")\] 269 | 270 | File URLs are rarely used in [Web pages](/wiki/Web_page "Web page") on 271 | the public Internet, since they imply that a file exists on the 272 | designated host. The *host* specifier can be used to retrieve a file 273 | from an external source, although no specific file-retrieval protocol is 274 | specified; and using it should result in a message that informs the user 275 | that no mechanism to access that machine is available. 276 | 277 | References\[[edit](/w/index.php?title=File_URI_scheme&action=edit§ion=10 "Edit section: References")\] 278 | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 279 | 280 |
281 | 282 | 1.
283 | 284 |
285 | 286 | **[\^](#cite_ref-1)** ["The file URI Scheme: 288 | draft-ietf-appsawg-file-scheme-03"](https://tools.ietf.org/html/draft-ietf-appsawg-file-scheme-03){.external 289 | .text}. Internet Engineering Task Force (IETF). 23 July 2015. Retrieved 21 291 | Aug 2015.  294 | 2.
295 | 296 |
297 | 298 | **[\^](#cite_ref-2)** Risney, Dave (2006). ["File URIs in 300 | Windows"](http://blogs.msdn.com/b/ie/archive/2006/12/06/file-uris-in-windows.aspx){.external 301 | .text}. *IEBlog*. Microsoft Corporation. Retrieved 31 303 | July 2013.  306 | 3.
307 | 308 |
309 | 310 | **[\^](#cite_ref-3)** [File URIs in Windows - IEBlog - Site Home - 312 | MSDN 313 | Blogs](http://blogs.msdn.com/ie/archive/2006/12/06/file-uris-in-windows.aspx){.external 314 | .text}. Blogs.msdn.com (2006-12-06). Retrieved on 2014-03-08. 315 | 4.
316 | 317 |
318 | 319 | **[\^](#cite_ref-4)** [The Bizarre and Unhappy Story of 'file:' 321 | URLs - Free Associations - Site Home - MSDN 322 | Blogs](http://blogs.msdn.com/freeassociations/archive/2005/05/19/420059.aspx){.external 323 | .text}. Blogs.msdn.com (2005-05-19). Retrieved on 2014-03-08. 324 | 325 |
326 | 327 | External links\[[edit](/w/index.php?title=File_URI_scheme&action=edit§ion=11 "Edit section: External links")\] 328 | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 329 | 330 | - [File URLs](http://www.cs.tut.fi/~jkorpela/fileurl.html){.external 331 | .text} 332 | 333 | 399 | 400 | ![](//en.wikipedia.org/wiki/Special:CentralAutoLogin/start?type=1x1){width="1" 401 | height="1"} 402 | 403 |
404 | 405 |
406 | 407 | Retrieved from 408 | "" 409 | 410 |
411 | 412 | 436 | 437 |
438 | 439 |
440 | 441 |
442 | 443 |