$files→copy()
Copy all files recursively from one directory ($src) to another directory ($dst)
Unlike PHP's copy() function, this method performs a recursive copy by default, ensuring that all files and directories in the source ($src) directory are duplicated
in the destination ($dst) directory.
This method can also be used to copy single files. If a file is specified for $src, and only a path is specified for $dst, then the original filename will be retained in $dst.
Example
// Copy everything from /site/assets/cache/foo/ to /site/assets/cache/bar/
$copyFrom = $config->paths->cache . "foo/";
$copyTo = $config->paths->cache . "bar/";
$files->copy($copyFrom, $copyTo); Usage
// basic usage
$bool = $files->copy(string $src, string $dst);
// usage with all arguments
$bool = $files->copy(string $src, string $dst, $options = []);Arguments
| Name | Type(s) | Description |
|---|---|---|
$src | string | Path to copy files from, or filename to copy. |
$dst | string | Path (or filename) to copy file(s) to. Directory is created if it doesn't already exist. |
$options (optional) | bool array | Array of options:
|
Return value
boolTrue on success, false on failure.
Exceptions
Method can throw exceptions on error:
WireException- iflimitPathoption is used and either $src or $dst is not allowed
API reference based on ProcessWire core version 3.0.252