简体   繁体   English

从外部php文件访问代码点火器

[英]Access code igniter from an external php file

I'm trying to access Code Igniter file from outside php file. 我正在尝试从外部php文件访问Code Igniter文件。

In my php file the destination folder is : 在我的php文件中,目标文件夹为:

$doc_dir = '../admin/public/upload';

But my php file is located in the same level of admin folder(which is outside CI). 但是我的php文件位于admin文件夹的同一级别(位于CI外部)。 So could you please suggest me how do I access the 'upload' folder (which is in CI) from student folder 因此,您能建议我如何从学生文件夹访问“上传”文件夹(位于CI中)吗?

    /admin
      public
      upload
   /student
      abc.php

Try one of these: THis: 请尝试以下方法之一:

$doc_dir = dirname(__FILE__) . '/admin/public/upload';

Or This: 或这个:

$doc_dir = explode("/",getcwd());
$doc_dir[count($doc_dir)-1] = "admin";
$doc_dir = implode("/",$doc_dir);
$doc_dir = $doc_dir."/public/upload";

One of the above approach will work. 以上方法之一将起作用。 The approach is to get the absolute path, so there are many ways to get absolute path, you can implement in your own way which you like. 方法是获取绝对路径,因此有很多方法可以获取绝对路径,您可以按照自己喜欢的方式实现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM