Not allowed to load local resource: file:///

╄→гoц情女王★ 提交于 2019-12-31 04:47:06

问题


I have some images in a folder called "Slides" in my project; I am trying to access those images; but it gives me the following error:

Not allowed to load local resource: file:///C:/xampp/htdocs/MyProject/Slides/123_completed.jpg 

where is "file://" coming from?! (Probably thats the problem!)

this is my method to scan the images in the folder called "Slides"

the following line of code is in my

$this->signage_Path = realpath(APPPATH . '../Slides');
public function get_Signage_Images() {
    $files = scandir($this->signage_Path);
    $newFiles = array_diff($files, array('.', '..'));
    $images = array();
    foreach ($newFiles as $file) {
        $ext = pathinfo($file, PATHINFO_EXTENSION);
        if ($ext == "jpg") {
            $images[] = array(
                'url' => $this->signage_Path.'\\'.$file,
                'thumb_url' => $this->signage_Path.'\\'.$file,
            );
        }
    }
    return $images;
}

If you need more clarification, please let me know which part!

Thanks


回答1:


It's probably coming from your APPPATH constant in realpath(). Should be more like $this->signage_Path = 'MyProject/Slides', without realpath(). PHP cannot access a file that is not on a Server, without Client permission. Of course, I really don't know what your sinage_Path is supposed to be. This should just give you an idea of your problem.



来源:https://stackoverflow.com/questions/20434624/not-allowed-to-load-local-resource-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!