copy
(PHP 4, PHP 5, PHP 7, PHP 8)
copy — 拷贝文件
参数
from-
源文件路径。
to-
目标路径。如果
to是一个 URL,则如果封装协议不支持覆盖已有的文件时拷贝操作会失败。警告如果目标文件已存在,将会被覆盖。
context-
A valid context resource created with stream_context_create().
示例
示例 #1 copy() 例子
<?php
$file = 'example.txt';
$newfile = 'example.txt.bak';
if (!copy($file, $newfile)) {
echo "failed to copy $file...\n";
}
?>参见
- move_uploaded_file() - 将上传的文件移动到新位置
- rename() - 重命名一个文件或目录
- The section of the manual about handling file uploads