Cannot open local file - Chrome: Not allowed to load local resource

后端 未结 14 1630
不知归路
不知归路 2020-11-22 12:01

Test browser: Version of Chrome: 52.0.2743.116

It is a simple javascript that is to open an image file from local like \'C:\\002.jpg\'

function run(         


        
14条回答
  •  萌比男神i
    2020-11-22 12:48

    There is a workaround using Web Server for Chrome.
    Here are the steps:

    1. Add the Extension to chrome.
    2. Choose the folder (C:\images) and launch the server on your desired port.

    Now easily access your local file:

    function run(){
       // 8887 is the port number you have launched your serve
       var URL = "http://127.0.0.1:8887/002.jpg";
    
       window.open(URL, null);
    
    }
    run();
    

    PS: You might need to select the CORS Header option from advanced setting incase you face any cross origin access error.

提交回复
热议问题