如何使用PHP将文件从一个目录复制到另一个目录? [英] How to copy a file from one directory to another using PHP?
本文介绍了如何使用PHP将文件从一个目录复制到另一个目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我在 foo
目录中有一个档案 test.php
,以及 bar
。如何用 foo / test.php
使用替换
bar / test.php
/ code>?
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
using PHP
? I'm on Windows XP, a cross platform solution would be great but windows preferred.
推荐答案
您可以使用 copy()
功能:
// Will copy foo/test.php to bar/test.php
// overwritting it if necessary
copy('foo/test.php', 'bar/test.php');
从其手册页引用几个相关句子:
Quoting a couple of relevant sentences from its manual page :
将文件源的副本复制到
dest。
如果目标
文件已存在,则将覆盖
。
这篇关于如何使用PHP将文件从一个目录复制到另一个目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文