- -[](){#top} -
- -
- -
- -
- -file URI scheme {#firstHeading .firstHeading lang="en"} -=============== - -
- -
- -From Wikipedia, the free encyclopedia - -
- -
- -
- -
- -Jump to: [navigation](#mw-head), [search](#p-search) - -
- -
- -+--------------------------------------+--------------------------------------+ -|
| This | -| | article **needs additional citations | -| [![](//upload.wikimedia.org/wikipedi | for | -| a/en/thumb/9/99/Question_book-new.sv | [verification](/wiki/Wikipedia:Verif | -| g/50px-Question_book-new.svg.png){wi | iability "Wikipedia:Verifiability")* | -| dth="50" | *. | -| height="39" | Please | -| edia/en/thumb/9/99/Question_book-new | help [improve this | -| .svg/75px-Question_book-new.svg.png | article](//en.wikipedia.org/w/index. | -| 1.5x, //upload.wikimedia.org/wikiped | php?title=File_URI_scheme&action=edi | -| ia/en/thumb/9/99/Question_book-new.s | t){.external | -| vg/100px-Question_book-new.svg.png 2 | .text} by [adding citations to | -| x"}](/wiki/File:Question_book-new.sv | reliable | -| g){.image} | sources](/wiki/Help:Introduction_to_ | -| | referencing_with_Wiki_Markup/1 "Help | -|
| :Introduction to referencing with Wi | -| | ki Markup/1"). | -| | Unsourced material may be challenged | -| | and removed. *(October 2012)* | -| | *([Learn how and when to remove this | -| | template | -| | message](/wiki/Help:Maintenance_temp | -| | late_removal "Help:Maintenance templ | -| | ate removal"))* | -+--------------------------------------+--------------------------------------+ - -The **file URI scheme** is a [URI -scheme](/wiki/URI_scheme "URI scheme"){.mw-redirect} specified in [RFC -1630](//tools.ietf.org/html/rfc1630){.external .mw-magiclink-rfc} and -[RFC 1738](//tools.ietf.org/html/rfc1738){.external .mw-magiclink-rfc}, -typically used to retrieve files from within one's own computer. The -[Internet Engineering Task -Force](/wiki/Internet_Engineering_Task_Force "Internet Engineering Task Force") -(IETF) has published a series of [draft -documents](/wiki/Draft_document "Draft document") obsoleting these RFCs. -They say that they are trying to define "a syntax that is compatible -with most extant implementations, while attempting to push towards a -stricter subset of 'ideal' constructs." Doing so involves the -[deprecation](/wiki/Deprecation "Deprecation") of some less common or -outdated constructs, some of which are described below. While they may -work on some current systems, formulations that are not consistent with -the [standardization](/wiki/Standardization "Standardization") process -going forward will not have the useful lifetime that others will. The -drafts are not final, and should be consulted for up to date -information.^[\[1\]](#cite_note-1)^ - -
- -
- -Contents --------- - -
- -- [1 Format](#Format) -- [2 Meaning of - slash character](#Meaning_of_slash_character) -- [3 Examples](#Examples) - - [3.1 Unix](#Unix) - - [3.2 Windows](#Windows) -- [4 Implementations](#Implementations) - - [4.1 Windows](#Windows_2) - - [4.1.1 Legacy URLs](#Legacy_URLs) - - [4.2 Web - pages](#Web_pages) -- [5 References](#References) -- [6 External - links](#External_links) - -
- -Format\[[edit](/w/index.php?title=File_URI_scheme&action=edit§ion=1 "Edit section: Format")\] --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -A file URI takes the form of - - file://host/path - -where ***host*** is the [fully qualified domain -name](/wiki/Fully_qualified_domain_name "Fully qualified domain name") -of the system on which the *path* is accessible, and ***path*** is a -hierarchical directory path of the form -*directory*/*directory*/.../*name*. If *host* is omitted, it is taken to -be "[localhost](/wiki/Localhost "Localhost")", the machine from which -the URL is being interpreted. Note that when omitting host, the slash is -not omitted (while "file:///foo.txt" is valid, "file://foo.txt" is not, -although some interpreters manage to handle the latter). - -\[[RFC 3986](//tools.ietf.org/html/rfc3986){.external -.mw-magiclink-rfc}\] includes additional information about the treatment -of ".." and "." segments in URIs. - -Meaning of slash character\[[edit](/w/index.php?title=File_URI_scheme&action=edit§ion=2 "Edit section: Meaning of slash character")\] --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -The **slash character** (/), depending on its position, has different -meanings within a file URL. - -- The // after the *file:* is part of the general syntax of - [URLs](/wiki/Uniform_resource_locator "Uniform resource locator"){.mw-redirect}. - (The double slash // should always appear in a file URL according to - the specification, but in practice many [Web - browsers](/wiki/Web_browser "Web browser") allow it to be omitted). -- The single slash between ***host*** and ***path*** is part of the - syntax of URLs. -- The slashes in ***path*** separate directory names in a hierarchical - system of directories and subdirectories. In this usage, the slash - is a general, system-independent way of separating the parts, and in - a particular host system it might be used as such in any pathname - (as in Unix systems). - -Examples\[[edit](/w/index.php?title=File_URI_scheme&action=edit§ion=3 "Edit section: Examples")\] --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -### Unix\[[edit](/w/index.php?title=File_URI_scheme&action=edit§ion=4 "Edit section: Unix")\] - -Here are two [Unix](/wiki/Unix "Unix") examples pointing to the same -/*etc*/*fstab* file: - - file://localhost/etc/fstab - file:///etc/fstab - -### Windows\[[edit](/w/index.php?title=File_URI_scheme&action=edit§ion=5 "Edit section: Windows")\] - -Here are some examples which may be accepted by some applications on -Windows systems, referring to the same, local file -*c:*\\*WINDOWS*\\*clock.avi* - - file://localhost/c|/WINDOWS/clock.avi - file:///c|/WINDOWS/clock.avi - file://localhost/c:/WINDOWS/clock.avi - -Here is the URI as understood by the Windows Shell -API:^[\[2\]](#cite_note-2)^ - - file:///c:/WINDOWS/clock.avi - -Implementations\[[edit](/w/index.php?title=File_URI_scheme&action=edit§ion=6 "Edit section: Implementations")\] ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - -### Windows\[[edit](/w/index.php?title=File_URI_scheme&action=edit§ion=7 "Edit section: Windows")\] - -On Microsoft Windows systems, the normal colon (:) after a device letter -has sometimes been replaced by a vertical bar (|) in file URLs. This -reflected the original URL syntax, which made the colon a reserved -character in a path part. - -Since [Internet Explorer -4](/wiki/Internet_Explorer_4 "Internet Explorer 4"), file URIs have been -standardized on Windows, and should follow the following scheme. This -applies to all applications which use URLMON or SHLWAPI for parsing, -fetching or binding to URIs. To convert a path to a URL, use -`UrlCreateFromPath`, and to convert a URL to a path, use -`PathCreateFromUrl`.^[\[3\]](#cite_note-3)^ - -To access a file "the file.txt", the following might be used. - -For a network location: - - file://hostname/path/to/the%20file.txt - -Or for a local file, the hostname is omitted, but the slash is not (note -the third slash): - - file:///c:/path/to/the%20file.txt - -This is not the same as providing the string "localhost" or the dot "." -in place of the hostname. The string "localhost" will attempt to access -the file as \\\\localhost\\c:\\path\\to\\the file.txt, which will not -work since the colon is not allowed in a share name. The dot "." results -in the string being passed as \\\\.\\c:\\path\\to\\the file.txt, which -will work for local files, but not shares on the local system. For -example file://./sharename/path/to/the%20file.txt will not work, because -it will result in *sharename* being interpreted as part of the -DOSDEVICES namespace, not as a network share. - -The following outline roughly describes the requirements. - -- The colon should be used, and should *not* be replaced with a - vertical bar for Internet Explorer. -- Forward slashes should be used to delimit paths. -- Characters such as the hash (\#) or question mark (?) which are part - of the filename should be - [percent-encoded](/wiki/Percent-encoding "Percent-encoding"). -- Characters which are not allowed in URIs, but which are allowed in - filenames, must also be percent-encoded. For example, any of - "**{}\`\^** " and all control characters. In the example above, the - space in the filename is encoded as %20. -- Characters which are allowed in both URIs and filenames must NOT - be percent-encoded. -- Must not use legacy ACP encodings. (ACP code pages are specified by - DOS CHCP or Windows Control Panel language setting.) -- Unicode characters outside of the [ASCII](/wiki/ASCII "ASCII") range - must be [UTF-8](/wiki/UTF-8 "UTF-8") encoded, and those UTF-8 - encodings must be percent-encoded. - -Use the provided functions if possible. If must create a URL -programmatically and cannot access SHLWAPI.dll (for example from script, -or another programming environment where the equivalent functions are -not available) the above outline will help. - -#### Legacy URLs\[[edit](/w/index.php?title=File_URI_scheme&action=edit§ion=8 "Edit section: Legacy URLs")\] - -To aid the installed base of legacy applications on Win32 -`PathCreateFromUrl` recognizes certain URLs which do not meet these -criteria, and treats them uniformly. These are called "legacy" file URLs -as opposed to "healthy" file URLs.^[\[4\]](#cite_note-4)^ - -In the past, a variety of other applications have used other systems. -Some added an additional two slashes. For example, -\\\\remotehost\\share\\dir\\file.txt, would become -file:////remotehost/share/dir/file.txt instead of the "healthy" -file://remotehost/share/dir/file.txt. - -### Web pages\[[edit](/w/index.php?title=File_URI_scheme&action=edit§ion=9 "Edit section: Web pages")\] - -File URLs are rarely used in [Web pages](/wiki/Web_page "Web page") on -the public Internet, since they imply that a file exists on the -designated host. The *host* specifier can be used to retrieve a file -from an external source, although no specific file-retrieval protocol is -specified; and using it should result in a message that informs the user -that no mechanism to access that machine is available. - -References\[[edit](/w/index.php?title=File_URI_scheme&action=edit§ion=10 "Edit section: References")\] ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -
- -1.
- -
- - **[\^](#cite_ref-1)** ["The file URI Scheme: - draft-ietf-appsawg-file-scheme-03"](https://tools.ietf.org/html/draft-ietf-appsawg-file-scheme-03){.external - .text}. Internet Engineering Task Force (IETF). 23 July 2015. Retrieved 21 - Aug 2015.  -2.
- -
- - **[\^](#cite_ref-2)** Risney, Dave (2006). ["File URIs in - Windows"](http://blogs.msdn.com/b/ie/archive/2006/12/06/file-uris-in-windows.aspx){.external - .text}. *IEBlog*. Microsoft Corporation. Retrieved 31 - July 2013.  -3.
- -
- - **[\^](#cite_ref-3)** [File URIs in Windows - IEBlog - Site Home - - MSDN - Blogs](http://blogs.msdn.com/ie/archive/2006/12/06/file-uris-in-windows.aspx){.external - .text}. Blogs.msdn.com (2006-12-06). Retrieved on 2014-03-08. -4.
- -
- - **[\^](#cite_ref-4)** [The Bizarre and Unhappy Story of 'file:' - URLs - Free Associations - Site Home - MSDN - Blogs](http://blogs.msdn.com/freeassociations/archive/2005/05/19/420059.aspx){.external - .text}. Blogs.msdn.com (2005-05-19). Retrieved on 2014-03-08. - -
- -External links\[[edit](/w/index.php?title=File_URI_scheme&action=edit§ion=11 "Edit section: External links")\] ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -- [File URLs](http://www.cs.tut.fi/~jkorpela/fileurl.html){.external - .text} - - - -![](//en.wikipedia.org/wiki/Special:CentralAutoLogin/start?type=1x1){width="1" -height="1"} - -
- -
- -Retrieved from -"" - -
- - - -
- -
- -
- -