Call Controller method of CodeIgniter outside Application directory

前端 未结 1 843
梦如初夏
梦如初夏 2020-12-21 05:56

I have one directory \"Store\" which is outside Application directory of CodeIgniter. Here I need to call one controller method from \"Store\" directory.

Is is poss

1条回答
  •  清酒与你
    2020-12-21 06:06

    As far as I know, using $this->load (Loader class i.e.), you can't. Even if you directly include like in the following way:

    application/controllers/test.php

    handle();
        }
    }
    

    dummy.php

    It(including) won't work because you specifically disallowed direct access! But, if you don't disallow that, then, your controller code is prone to exploitation, and you won't have a problem.


    So, one way to do it if the other controller part of another codeigniter project is, using command line.

    dummy.php

    handle();
        }
    }
    

    application/controllers/test.php

    public function handle(){
        exec("cd /absolute/path/to/dummyproject; php index.php dummy handle;");
    }
    

    You can further find out how to pass command line arguments too.

    0 讨论(0)
提交回复
热议问题