How to specify a local file within html using the file: scheme?
The file:
URL scheme refers to a file on the client machine. There is no hostname in the file:
scheme; you just provide the path of the file. So, the file on your local machine would be file:///~User/2ndFile.html
. Notice the three slashes; the hostname part of the URL is empty, so the slash at the beginning of the path immediately follows the double slash at the beginning of the URL. You will also need to expand the user's path; ~
does no expand in a file:
URL. So you would need file:///home/User/2ndFile.html
(on most Unixes), file:///Users/User/2ndFile.html
(on Mac OS X), or file:///C:/Users/User/2ndFile.html
(on Windows).
Many browsers, for security reasons, do not allow linking from a file that is loaded from a server to a local file. So, you may not be able to do this from a page loaded via HTTP; you may only be able to link to file:
URLs from other local pages.
the "file://" url protocol can only be used to locate files in the file system of the local machine. since this html code is interpreted by a browser, the "local machine" is the machine that is running the browser.
if you are getting file not found errors, i suspect it is because the file is not found. however, it could also be a security limitation of the browser. some browsers will not let you reference a filesystem file from a non-filesystem html page. you could try using the file path from the command line on the machine running the browser to confirm that this is a browser limitation and not a legitimate missing file.