不允许加载本地资源:file:/// [英] Not allowed to load local resource: file:///

查看:2395
本文介绍了不允许加载本地资源:file:///的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目中有一些名为幻灯片的文件夹中有一些图片;我试图访问这些图像;但它给我以下错误:

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 

file://来自哪里?

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

这是我在名为幻灯片的文件夹中扫描图片的方法

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

以下代码行在我的

$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!

感谢

推荐答案

这可能来自您的 APPPATH 常量在 realpath()。应该更像 $ this-> signage_Path ='MyProject / Slides',而不是 realpath()。 PHP无法访问不在服务器上的文件,没有客户端权限。当然,我真的不知道你的 sinage_Path 应该是什么。这应该只是给你一个想法你的问题。

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.

这篇关于不允许加载本地资源:file:///的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆