How to copy a file from one directory to another using PHP?

后端 未结 8 922
暗喜
暗喜 2020-11-28 06:38

Say I\'ve got a file test.php in foo directory as well as bar. How can I replace bar/test.php with foo/test.php

8条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-28 07:15

    You could use the rename() function :

    rename('foo/test.php', 'bar/test.php');
    

    This however will move the file not copy

提交回复
热议问题