简体   繁体   中英

Access code igniter from an external php file

I'm trying to access Code Igniter file from outside php file.

In my php file the destination folder is :

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

But my php file is located in the same level of admin folder(which is outside CI). So could you please suggest me how do I access the 'upload' folder (which is in CI) from student folder

    /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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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