【问题标题】:How to change current directory to another directory如何将当前目录更改为另一个目录
【发布时间】:2012-10-25 06:38:38
【问题描述】:

我想将一些文件从当前目录包含/上传到另一个目录,如图所示。如果我这样做

    1. $currdir = getcwd();      
    2. chdir('/home');
    3. echo '<br/>'.getcwd();       
    4. chdir('/home/second/');
    5. echo '<br/>'.getcwd();       
    6. $dirs = array_filter(glob('*'), 'is_dir');
    7. print_r($dirs);
    8. chdir($currdir);

正确显示子目录列表

但如果我将第 4 行更改为 chdir('/home/first/'); 它给了我一个空数组。

我如何从这样的目录结构中读取/包含/上传文件。

【问题讨论】:

    标签: php file include directory


    【解决方案1】:

    你可以使用

    chdir('../home/second/');
    

    【讨论】:

      【解决方案2】:

      您可以使用名为 system('Cd /home/First/Publich_Html'); 的函数 要么 chdir('../home/second/');

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-07-26
        • 2021-07-03
        • 1970-01-01
        • 1970-01-01
        • 2011-12-05
        • 2014-12-02
        • 2015-02-22
        相关资源
        最近更新 更多