doupingtang9627 2016-10-11 21:38
浏览 27
已采纳

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

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
  • 写回答

1条回答 默认 最新

  • douzhi1972 2016-10-11 21:51
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?