3

I am trying to open a file which is on the local disk on firefox using html on a ubuntu machine. But, I am facing file not found error. My code is as follows:

    <body>
        <a href="/home/abc/workspace/logfile.log">LOG FILE</a>
    </body>

I tried using file:/// but still the file is not getting opened.

Mickstjohn09
  • 103
  • 2
  • 2
  • 10
  • You could change your file so its formatted in javascript and open it with or maybe fire-up a local webserver to host the files: **https://stackoverflow.com/questions/27977972/how-do-i-setup-a-local-http-server-using-python** – andrew pate Aug 30 '20 at 12:43

2 Answers2

12

Use the file:/// protocol:

file:///home/abc/workspace/logfile.log

It does not work however for security reasons in a general case. You can disable the security check by editing about:config, or by using an extension, however I would not recommend it.

This is the about:config key:

security.fileuri.strict_origin_policy

It is true by default, you can set it to false.

meskobalazs
  • 15,741
  • 2
  • 40
  • 63
-2

You cannot access file system using the browser. For obvious security reasons.

Paran0a
  • 3,359
  • 3
  • 23
  • 48
  • 1
    I have numerous HTML documents on my local disk. I am the file owner and can view/edit/delete them using other tools. I do not understand why mozilla deems it insecure to render them for me when I explicitly type the file:/// URL into the browser. – Bernhard Bodenstorfer Apr 11 '17 at 07:44