0

I want to display an image that is stored locally on my disk. I have tried this:

     image.src = "file:/Users/user/Desktop/photo.png";

But I get the following error: "Not Allowed to Load Local Resources". I use Google Chrome on Mac.

3
  • 1
    The error means exactly what it says. JavaScript is not allowed to access the file system. If you are working without a server, just make the path relative to the location of the .html file, not relative to C:\ Commented Apr 25, 2019 at 22:12
  • You are not able to open files from a local drive through JavaScript when loading the HTML container file from an HTTP server. Try uploading your image to an external server to serve them trough HTTP. Commented Apr 25, 2019 at 22:12
  • Launch the Google Chrome browser from the command line window with the additional argument '–allow-file-access-from-files'. Commented Apr 25, 2019 at 22:49

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.