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

后端 未结 14 1448
不知归路
不知归路 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条回答
  •  南笙
    南笙 (楼主)
    2020-11-22 12:42

    This issue come when I am using PHP as server side language and the work around was to generate base64 enconding of my image before sending the result to client

    $path = 'E:/pat/rwanda.png';
    $type = pathinfo($path, PATHINFO_EXTENSION);
    $data = file_get_contents($path);
    $base64 = 'data:image/' . $type . ';base64,' . base64_encode($data);
    

    I think may give someone idea to create his own work around

    Thanks

提交回复
热议问题