Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iframe访问Codeigniter中的PHP文件_Php_Codeigniter_Iframe - Fatal编程技术网

Iframe访问Codeigniter中的PHP文件

Iframe访问Codeigniter中的PHP文件,php,codeigniter,iframe,Php,Codeigniter,Iframe,我想在codeigniter中创建iframe,它可以访问我本地文件夹中的一个php文件。像这样 <iframe src="assets/kcfinder/browse.php?type=files&dir=/assets/admin/images" frameborder="0" ></iframe> 但显示器总是将其重定向到404页。我怎样才能修好它 非常感谢。如果您使用的是CI,那么直接调用php文件是不明智的。改为创建一个控制器并调用它。比如:

我想在codeigniter中创建iframe,它可以访问我本地文件夹中的一个php文件。像这样

<iframe src="assets/kcfinder/browse.php?type=files&dir=/assets/admin/images" frameborder="0" ></iframe>

但显示器总是将其重定向到404页。我怎样才能修好它


非常感谢。

如果您使用的是CI,那么直接调用php文件是不明智的。改为创建一个控制器并调用它。比如:

    <?php

    require_once dirname(__FILE__) . "/base.php";

        class fck extends BaseController {

        function __construct() {
            parent::__construct();
            $this->load->model('myModel');
        }


        function browse($type,$dir)  { 
            $data['directory'] = $this->myModel->loadDirContent($type,$dir);
            $this->load->view("fck/browse", $data); 
        }
    }
    ?>

然后,您的iframe如下所示:

<iframe src="/fck/browse/files/assets/admin/images" frameborder="0" ></iframe>


请注意,在上面的URI中“浏览”之后,您实际上是在提交数据。首先是由浏览函数读取为“$type”的内容,即“文件”,然后是路径本身,即包含破折号的数据。可以说,这不再是URL的一部分。

如果不知道文件夹结构,我们如何知道服务器返回404的原因?文件夹和文件已经存在。返回404,因为我不知道在控制器中写入时必须使用什么函数。我已经做了一个控制器重定向该url,但它不工作。