Option 1: Using file://
links
You can point your browser to any folder on your computer using
file:///path/to/folder
A list of files should show up, similar to a File Browser. Web Browsers can also parse .html files, show images, play some video formats, open text and xml files from your local machine. Just point your browser to file:///path/to/file.ext
.
Option 2: Running an HTTP-Server
If you need to parse files other than .html (e.g. php
files) or need to access them from another computer, you need to run an http server like apache
, nginx
or Python SimpleHTTPServer
on your local machine. Then you can use http://
and if configured also https://
URLs.
Here is a nice list of Instant HTTP Server options.
Example:
Start an Instant http-Server using Python and SimpleHTTPServer
Python 2.x:
cd /home/user/folder && python -m SimpleHTTPServer 8082
Python 3.x:
cd /home/user/folder && python3 -m http.server 8082
Then open your preferred browser: http://localhost:8082/
UPDATE:
After you added your specific need in the comments, I would recommend reading this page why local links inside http pages are not allowed. Included is also a workaround (overriding the security policy using NoScript).
For security purposes, Mozilla applications block links to local files (and directories) from remote files. This includes linking to files on your hard drive, on mapped network drives, and accessible via Uniform Naming Convention (UNC) paths. This prevents a number of unpleasant possibilities
I see three options:
- Use an (Instant) HTTP Server, then you can include
http://localhost:8082/file.js
directly.
- Overrde Firefox security policy and use a
file://
link (I would not do it when other options exist)
- Let the Server access the file via http, smb or ssh connection to serve it directly (if you're behind a router or firewall, you need to take care of port forwarding). This is quite complicated to achieve, but is the only option that enables access from other machines (only while your computer is online).
Note: For better answers, always write the question as specific as possible from the beginning.