Share on Facebook Share on Twitter Email
Answers.com

File URI scheme

 
Wikipedia: File URI scheme

The file: URI is a URI scheme specified in RFC 1630 and RFC 1738, typically used to retrieve files from within one's own computer.

Contents

Format

A file: URI takes the form of

file://host/path

where host is the 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", the machine from which the URL is being interpreted. Note that when omitting host you do not omit the slash ("file:///foo.bar" is ok, while "file://foo.bar" is not, no matter some interpreters manage to handle the latter. )

Meaning of slash character

The slash character (/), depending on its position, is used in different meanings in a file URL.

  • The // after the file: is part of the general syntax of URLs. (The double slash // should always appear in a file URL according to the specification, but in practice many Web browsers allow you to omit it, in some cases at least.)
  • The single slash between host and path is part of the syntax of file URLs.
  • And 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 a pathname (as in Unix systems).

Examples

Linux

Here are two linux examples pointing to the same /etc/fstab file:

file://localhost/etc/fstab
file:///etc/fstab

Windows

Here are some examples valid for Windows systems, referring to the same file c:\WINDOWS\clock.avi

file://localhost/c|/WINDOWS/clock.avi
file:///c|/WINDOWS/clock.avi
file://localhost/c:/WINDOWS/clock.avi
file:///c:/WINDOWS/clock.avi

While the last is the most obvious and human-readable, the first one is the most complete and correct one.

Things to consider

Windows

On MS 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.

For network shares, add an additional two slashes. For example, \\remotehost\share\dir\file.txt, becomes file:////remotehost/share/dir/file.txt.

Usually interpreters manage to access both file://localhost///remotehost/share/dir/file.txt, and file:////remotehost/share/dir/file.txt

Web pages

file: URIs are rarely used in Web pages on the Internet, since they make the assumption that such a file exists on the client's computer. 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.

Mozilla

Mozilla browsers refuse to follow file: links on a page that it has fetched with the HTTP protocol, so that the page's own URL is an http: URL. When you click on such a link, nothing happens. The purpose is security: to prevent a remote page from executing a program on the visitor's computer. The file: links work on Mozilla on pages that are local files on the user's disk. It is not a surprise that Firefox 3.5.3 does nothing when requesting:

file:////remotehost/share/dir/file.txt 

(because it is a file on a remote host), however it successfully opens:

file://localhost///remotehost/share/dir/file.txt

or its equivalent:

file://///remotehost/share/dir/file.txt 

as it is referred to as a file on the local host.

Mozilla browsers can be configured to override this security restriction as detailed in Mozillazine's "Links to Local Pages Don't Work".

Mozilla browsers also treat file: URLs similarly to the Gopher protocol in the way a directory is represented textually (i.e. the source) and graphically.

Internet Explorer

Internet Explorer browsers, prior to version 7, will attempt to access file: URLs even if they reside on pages fetched over HTTP.[citation needed]

Other

The original Web browser, WorldWideWeb, provided editing of resources in file: space [1]. Amaya still has this ability.

External links


Search unanswered questions...
Enter a question here...
Search: All sources Community Q&A Reference topics
 
 

 

Copyrights:

Wikipedia. This article is licensed under the Creative Commons Attribution/Share-Alike License. It uses material from the Wikipedia article "File URI scheme" Read more