close

[Solved] Cannot open local file – Chrome: Not allowed to load local resource

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Cannot open local file – Chrome: Not allowed to load local resource in javascript. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Cannot open local file – Chrome: Not allowed to load local resource Error Occurs?

Today I get the following error Cannot open local file – Chrome: Not allowed to load local resource in javascript.

How To Solve Cannot open local file – Chrome: Not allowed to load local resource Error ?

  1. How To Solve Cannot open local file – Chrome: Not allowed to load local resource Error ?

    To Solve Cannot open local file – Chrome: Not allowed to load local resource Error You won't be able to load an image outside of the project directory or from a user level directory, hence the “cannot access local resource warning”.

  2. Cannot open local file – Chrome: Not allowed to load local resource

    To Solve Cannot open local file – Chrome: Not allowed to load local resource Error You won't be able to load an image outside of the project directory or from a user level directory, hence the “cannot access local resource warning”.

Solution 1

1) Open your terminal and type

npm install -g http-server

2) Go to the root folder that you want to serve you files and type:

http-server ./

3) Read the output of the terminal, something kinda http://localhost:8080 will appear.

Everything on there will be allowed to be got. Example:

background: url('http://localhost:8080/waw.png');

Solution 2

You won’t be able to load an image outside of the project directory or from a user level directory, hence the “cannot access local resource warning”.

But if you were to place the file in a root folder of your project like in {rootFolder}\Content\my-image.jpg and referenced it like so:

<img src="/Content/my-image.jpg" />

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also Read

Leave a Comment