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.

Vladislav
  • 273
  • 3
  • 15
  • 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:\ – Scott Marcus Apr 25 '19 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. – k3llydev Apr 25 '19 at 22:12
  • Launch the Google Chrome browser from the command line window with the additional argument '–allow-file-access-from-files'. – Moritz Roessler Apr 25 '19 at 22:49

0 Answers0