doumeitang572461 2014-04-16 08:20
浏览 6
已采纳

可以将PHP复制到新目录吗? [关闭]

just now I learnt how to create new directory in the server. So my question is it possible to copy a PHP file to the new directory created ?

Here's what i come up with

    mkdir('/home/user/public_html/ref/' . $cid . "_" . $gid, 0777);
   copy('/home/user/public_html/ref/index.php' ,'/home/user/public_html/ref/' . $cid . "_" . $gid);
  • 写回答

1条回答 默认 最新

  • dotws86260 2014-04-16 08:35
    关注

    You are correct to use copy() see PHP docs on copy here.

    The example they offer is...

    <?php
      $file = 'example.txt';
      $newfile = 'example.txt.bak';
    
      if (!copy($file, $newfile)) {
          echo "failed to copy $file...
    ";
      }
    ?>
    

    Your syntax is incorrect as the 2 argument in copy() needs to be the file name no the directory (as in example above). So try this.

          mkdir('/home/user/public_html/ref/' . $cid . "_" . $gid, 0777);
       copy('/home/user/public_html/ref/index.php' ,'/home/user/public_html/ref/' . $cid . "_" . $gid . '/index.php');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退